Skip to content

Commit 1277dcc

Browse files
author
Oscar Cobles
committed
new example for metal service token a-side to gcp redundant connection end-to-end solution
1 parent 7ce2dc6 commit 1277dcc

File tree

7 files changed

+233
-1
lines changed

7 files changed

+233
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ module "equinix-fabric-connection-gcp" {
6464
Run `terraform init -upgrade` and `terraform apply`.
6565

6666
-> **NOTE:**
67-
Completing BGP configuration in GCP side is not directly supported with current google terraform provider (v3.72.0). As a workaround this module take advantage of [terraform-google-gcloud](https://registry.terraform.io/modules/terraform-google-modules/gcloud/google/latest) module which allows use gcloud. However, it is only available for `linux` and `darwin` based operating systems. To run this module in a non-supported platfom, 'network_edge_configure_bgp' and 'gcp_configure_bgp' must remain false. Check this [issue](https://github.com/hashicorp/terraform-provider-google/issues/9582) to obtain further information.
67+
Setting up BGP configuration in GCP side is not directly supported with current google terraform provider (v3.72.0). As a workaround this module take advantage of [terraform-google-gcloud](https://registry.terraform.io/modules/terraform-google-modules/gcloud/google/latest) module which allows use gcloud. However, it is only available for `linux` and `darwin` based operating systems. To run this module in a non-supported platfom, 'network_edge_configure_bgp' and 'gcp_configure_bgp' must remain false. Check this [issue](https://github.com/hashicorp/terraform-provider-google/issues/9582) to obtain further information.
6868

6969
### Variables
7070

@@ -92,3 +92,4 @@ See <https://registry.terraform.io/modules/equinix-labs/fabric-connection-gcp/eq
9292

9393
- [Fabric Port connection](https://registry.terraform.io/modules/equinix-labs/fabric-connection-gcp/equinix/latest/examples/fabric-port-connection/)
9494
- [Network Edge device connection](https://registry.terraform.io/modules/equinix-labs/fabric-connection-gcp/equinix/latest/examples/network-edge-device-connection/)
95+
- [Service Token (a-side) Equinix Metal to GCP redundant connection End-to-End Solution](https://registry.terraform.io/modules/equinix-labs/fabric-connection-gcp/equinix/latest/examples/service-token-metal-to-gcp-connection/)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Complete Equinix Metal connection (a-side) to GCP (Google Cloud)
2+
3+
~> Equinix Metal connection with automated `a_side` service token is not generally available and may not be enabled yet for your organization.
4+
5+
~> This example is based on the Google Cloud topology to [establish 99.9% availability for Dedicated Interconnect](https://cloud.google.com/network-connectivity/docs/interconnect/tutorials/dedicated-creating-999-availability) where we configure two VLAN attachments in a single Google Cloud region, in separate edge availability domains (metro availability zones) and using a single cloud router.
6+
7+
This example demonstrates usage of the Equinix Connection GCP module to establish two Equinix Fabric L2 Connection from Equinix Metal (a-side) to GCP Interconnect using a redundant [A-Side Token](https://docs.equinix.com/en-us/Content/Interconnection/Fabric/service%20tokens/Fabric-Service-Tokens.htm).
8+
It will:
9+
10+
- Use an existing Equinix Metal project an existing Google Cloud project.
11+
- Create an Equinix Metal VLAN in selected metro Silicon Valley (SV).
12+
- Request an Equinix Metal shared redundant connection in SV.
13+
- Attach the Equinix Metal VLAN to the Virtual Circuit created for the Equinix Metal connection.
14+
- Create a Google Cloud Router.
15+
- Create a Google Cloud Interconnect/VLAN Attachment.
16+
- Provision two Equinix Fabric l2 connection for Google Cloud service profile with specified bandwidth and private peering.
17+
- Finish setting up BGP configuration on GCP side.
18+
19+
## Usage
20+
21+
To provision this example, you should clone the github repository and run terraform from within this directory:
22+
23+
```bash
24+
git clone https://github.com/equinix-labs/terraform-equinix-fabric-connection-gcp.git
25+
cd terraform-equinix-fabric-connection-gcp/examples/service-token-metal-to-gcp-connection
26+
terraform init
27+
terraform apply
28+
```
29+
30+
Note that this example may create resources which cost money. Run 'terraform destroy' when you don't need these resources.
31+
32+
## Variables
33+
34+
See <https://registry.terraform.io/modules/equinix-labs/fabric-connection-gcp/equinix/latest/examples/service-token-metal-to-gcp-connection?tab=inputs> for a description of all variables.
35+
36+
## Outputs
37+
38+
See <https://registry.terraform.io/modules/equinix-labs/fabric-connection-gcp/equinix/latest/examples/service-token-metal-to-gcp-connection?tab=outputs> for a description of all outputs.
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Configure the Equinix Provider
2+
# Please refer to provider documentation for details on supported authentication methods and parameters.
3+
# https://registry.terraform.io/providers/equinix/equinix/latest/docs
4+
provider "equinix" {
5+
client_id = var.equinix_provider_client_id
6+
client_secret = var.equinix_provider_client_secret
7+
}
8+
9+
# Configure the Google Cloud Platform Provider
10+
# https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/getting_started#adding-credentials
11+
provider "google" {
12+
project = var.gcp_project
13+
region = var.gcp_region
14+
}
15+
16+
## Retrieve an existing equinix metal project
17+
## If you prefer you can use resource equinix_metal_project instead to create a fresh project
18+
data "equinix_metal_project" "this" {
19+
project_id = var.metal_project_id
20+
}
21+
22+
locals {
23+
connection_name = format("conn-metal-gcp-%s", lower(var.fabric_destination_metro_code))
24+
}
25+
26+
# Create a new VLAN in Frankfurt
27+
resource "equinix_metal_vlan" "this" {
28+
description = format("VLAN in %s", var.fabric_destination_metro_code)
29+
metro = var.fabric_destination_metro_code
30+
project_id = data.equinix_metal_project.this.project_id
31+
}
32+
33+
## Request a connection service token in Equinix Metal
34+
resource "equinix_metal_connection" "this" {
35+
name = local.connection_name
36+
project_id = data.equinix_metal_project.this.project_id
37+
metro = var.fabric_destination_metro_code
38+
redundancy = var.redundancy_type == "SINGLE" ? "primary" : "redundant"
39+
type = "shared"
40+
service_token_type = "a_side"
41+
description = format("connection to GCP in %s", var.fabric_destination_metro_code)
42+
speed = format("%dMbps", var.fabric_speed)
43+
vlans = [equinix_metal_vlan.this.vxlan]
44+
}
45+
46+
## Configure the Equinix Fabric connection from Equinix Metal to GCP using the metal connection service token
47+
module "equinix-fabric-connection-gcp-primary" {
48+
source = "equinix-labs/fabric-connection-gcp/equinix"
49+
50+
fabric_notification_users = var.fabric_notification_users
51+
fabric_connection_name = local.connection_name
52+
fabric_destination_metro_code = var.fabric_destination_metro_code
53+
fabric_speed = var.fabric_speed
54+
fabric_service_token_id = equinix_metal_connection.this.service_tokens.0.id
55+
56+
# gcp_project = var.gcp_project_name // if unspecified, the project configured in the provided block will be used
57+
gcp_availability_domain = 1
58+
59+
gcp_gcloud_skip_download = false
60+
platform = var.platform
61+
62+
## BGP config
63+
gcp_configure_bgp = true
64+
# gcp_interconnect_customer_asn = // If unspecified, default value "65000" will be used
65+
}
66+
67+
## If redundancy_type is REDUNDANT, configure a secondary Equinix Fabric connection from Equinix Metal to GCP
68+
## using the metal connection service token
69+
module "equinix-fabric-connection-gcp-secondary" {
70+
source = "equinix-labs/fabric-connection-gcp/equinix"
71+
72+
count = var.redundancy_type == "REDUNDANT" ? 1 : 0
73+
74+
fabric_notification_users = var.fabric_notification_users
75+
fabric_connection_name = local.connection_name
76+
fabric_destination_metro_code = var.fabric_destination_metro_code
77+
fabric_speed = var.fabric_speed
78+
fabric_service_token_id = equinix_metal_connection.this.service_tokens.1.id
79+
80+
gcp_availability_domain = 2
81+
gcp_compute_create_router = false // we use the same cloud router of the primary connection
82+
gcp_compute_router_name = module.equinix-fabric-connection-gcp-primary.gcp_cloud_router_name
83+
84+
gcp_gcloud_skip_download = true
85+
platform = var.platform
86+
87+
## BGP config
88+
gcp_configure_bgp = true
89+
# gcp_interconnect_customer_asn = // If unspecified, default value "65000" will be used
90+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
output "connection_primary_details" {
2+
value = module.equinix-fabric-connection-gcp-primary
3+
}
4+
5+
output "connection_secondary_details" {
6+
value = var.redundancy_type == "REDUNDANT" ? module.equinix-fabric-connection-gcp-secondary : null
7+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
variable "equinix_provider_client_id" {
2+
type = string
3+
description = <<EOF
4+
API Consumer Key available under 'My Apps' in developer portal. This argument can also be specified with the
5+
EQUINIX_API_CLIENTID shell environment variable.
6+
EOF
7+
default = null
8+
}
9+
10+
variable "equinix_provider_client_secret" {
11+
type = string
12+
description = <<EOF
13+
API Consumer secret available under 'My Apps' in developer portal. This argument can also be specified with the
14+
EQUINIX_API_CLIENTSECRET shell environment variable.
15+
EOF
16+
default = null
17+
}
18+
19+
variable "gcp_project" {
20+
type = string
21+
description = "(Required) Name of the GCP project to manage resources in."
22+
}
23+
24+
variable "gcp_region" {
25+
type = string
26+
description = <<EOF
27+
The region in which the GCP resources and the Equinix port for GCP resides, i.e. 'us-west2'. If unspecified, this
28+
defaults to the region configured in the google provider.
29+
30+
NOTE: 'var.gcp_region' and 'var.fabric_destination_metro_code' must correspond to same location."
31+
EOF
32+
default = "us-west2" // Corresponds to Silicon Valley (SV) and Los Angeles (LA).
33+
}
34+
35+
variable "metal_project_id" {
36+
type = string
37+
description = "ID of the project where the connection is scoped to, used to look up the project."
38+
}
39+
40+
variable "fabric_notification_users" {
41+
type = list(string)
42+
description = "A list of email addresses used for sending connection update notifications."
43+
default = ["[email protected]"]
44+
}
45+
46+
variable "fabric_destination_metro_code" {
47+
type = string
48+
description = "Destination Metro code where the connection will be created."
49+
default = "SV" // Corresponds to Silicon Valley
50+
}
51+
52+
variable "fabric_speed" {
53+
type = number
54+
description = <<EOF
55+
Speed/Bandwidth in Mbps to be allocated to the connection. If unspecified, it will be used the minimum
56+
bandwidth available for the `Equinix Metal` service profile. Valid values are
57+
(50, 100, 200, 500, 1000, 2000, 5000, 10000).
58+
EOF
59+
default = 50
60+
}
61+
62+
variable "redundancy_type" {
63+
type = string
64+
description = "Whether to create a 'SINGLE' connection or 'REDUNDANT'."
65+
default = "REDUNDANT"
66+
}
67+
68+
variable "platform" {
69+
type = string
70+
description = <<EOF
71+
(Required) Platform this terraform module will run on. One of: linux, darwin.
72+
73+
NOTE: Configuration of the bgp customer ASN in google side is not directly supported with current google terraform
74+
provider (v3.72.0). As a workaround this module take advantage of 'terraform-google-gcloud' module which allows use
75+
gcloud. However, it is only available for `linux` and `darwin` based operating systems.
76+
EOF
77+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
terraform {
2+
required_version = ">= 0.13"
3+
4+
required_providers {
5+
equinix = {
6+
source = "equinix/equinix"
7+
version = ">= 1.7.0"
8+
}
9+
google = {
10+
source = "hashicorp/google"
11+
version = ">= 3.72.0"
12+
}
13+
}
14+
}

outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ output "gcp_cloud_router_id" {
6262
value = local.gcp_compute_router_id
6363
}
6464

65+
output "gcp_cloud_router_name" {
66+
description = "Google Cloud Router Name."
67+
value = var.gcp_compute_create_router ? google_compute_router.this[0].name : data.google_compute_router.this[0].name
68+
}
69+
6570
output "gcp_cloud_router_ip_address" {
6671
description = <<EOF
6772
Google Cloud Router IPv4 address + prefix length to be configured on CLOUD Router Interface for the interconnect

0 commit comments

Comments
 (0)