diff --git a/README.md b/README.md index 5574b53..5d86431 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ module "equinix-fabric-connection-gcp" { Run `terraform init -upgrade` and `terraform apply`. -> **NOTE:** -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. +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. ### Variables @@ -92,3 +92,4 @@ See Equinix Metal connection with automated `a_side` service token is not generally available and may not be enabled yet for your organization. + +~> 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. + +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). +It will: + +- Use an existing Equinix Metal project an existing Google Cloud project. +- Create an Equinix Metal VLAN in selected metro Silicon Valley (SV). +- Request an Equinix Metal shared redundant connection in SV. +- Attach the Equinix Metal VLAN to the Virtual Circuit created for the Equinix Metal connection. +- Create a Google Cloud Router. +- Create a Google Cloud Interconnect/VLAN Attachment. +- Provision two Equinix Fabric l2 connection for Google Cloud service profile with specified bandwidth and private peering. +- Finish setting up BGP configuration on GCP side. + +## Usage + +To provision this example, you should clone the github repository and run terraform from within this directory: + +```bash +git clone https://github.com/equinix-labs/terraform-equinix-fabric-connection-gcp.git +cd terraform-equinix-fabric-connection-gcp/examples/service-token-metal-to-gcp-connection +terraform init +terraform apply +``` + +Note that this example may create resources which cost money. Run 'terraform destroy' when you don't need these resources. + +## Variables + +See for a description of all variables. + +## Outputs + +See for a description of all outputs. diff --git a/examples/service-token-metal-to-gcp-connection/main.tf b/examples/service-token-metal-to-gcp-connection/main.tf new file mode 100644 index 0000000..589c563 --- /dev/null +++ b/examples/service-token-metal-to-gcp-connection/main.tf @@ -0,0 +1,90 @@ +# Configure the Equinix Provider +# Please refer to provider documentation for details on supported authentication methods and parameters. +# https://registry.terraform.io/providers/equinix/equinix/latest/docs +provider "equinix" { + client_id = var.equinix_provider_client_id + client_secret = var.equinix_provider_client_secret +} + +# Configure the Google Cloud Platform Provider +# https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/getting_started#adding-credentials +provider "google" { + project = var.gcp_project + region = var.gcp_region +} + +## Retrieve an existing equinix metal project +## If you prefer you can use resource equinix_metal_project instead to create a fresh project +data "equinix_metal_project" "this" { + project_id = var.metal_project_id +} + +locals { + connection_name = format("conn-metal-gcp-%s", lower(var.fabric_destination_metro_code)) +} + +# Create a new VLAN in Frankfurt +resource "equinix_metal_vlan" "this" { + description = format("VLAN in %s", var.fabric_destination_metro_code) + metro = var.fabric_destination_metro_code + project_id = data.equinix_metal_project.this.project_id +} + +## Request a connection service token in Equinix Metal +resource "equinix_metal_connection" "this" { + name = local.connection_name + project_id = data.equinix_metal_project.this.project_id + metro = var.fabric_destination_metro_code + redundancy = var.redundancy_type == "SINGLE" ? "primary" : "redundant" + type = "shared" + service_token_type = "a_side" + description = format("connection to GCP in %s", var.fabric_destination_metro_code) + speed = format("%dMbps", var.fabric_speed) + vlans = [equinix_metal_vlan.this.vxlan] +} + +## Configure the Equinix Fabric connection from Equinix Metal to GCP using the metal connection service token +module "equinix-fabric-connection-gcp-primary" { + source = "equinix-labs/fabric-connection-gcp/equinix" + + fabric_notification_users = var.fabric_notification_users + fabric_connection_name = local.connection_name + fabric_destination_metro_code = var.fabric_destination_metro_code + fabric_speed = var.fabric_speed + fabric_service_token_id = equinix_metal_connection.this.service_tokens.0.id + + # gcp_project = var.gcp_project_name // if unspecified, the project configured in the provided block will be used + gcp_availability_domain = 1 + + gcp_gcloud_skip_download = false + platform = var.platform + + ## BGP config + gcp_configure_bgp = true + # gcp_interconnect_customer_asn = // If unspecified, default value "65000" will be used +} + +## If redundancy_type is REDUNDANT, configure a secondary Equinix Fabric connection from Equinix Metal to GCP +## using the metal connection service token +module "equinix-fabric-connection-gcp-secondary" { + source = "equinix-labs/fabric-connection-gcp/equinix" + + count = var.redundancy_type == "REDUNDANT" ? 1 : 0 + + fabric_notification_users = var.fabric_notification_users + fabric_connection_name = local.connection_name + fabric_destination_metro_code = var.fabric_destination_metro_code + fabric_speed = var.fabric_speed + fabric_service_token_id = equinix_metal_connection.this.service_tokens.1.id + + gcp_availability_domain = 2 + gcp_compute_create_router = false // we use the same cloud router of the primary connection + gcp_compute_router_name = module.equinix-fabric-connection-gcp-primary.gcp_cloud_router_name + + gcp_gcloud_skip_download = true + platform = var.platform + + ## BGP config + gcp_configure_bgp = true + # gcp_interconnect_customer_asn = // If unspecified, default value "65000" will be used +} diff --git a/examples/service-token-metal-to-gcp-connection/outputs.tf b/examples/service-token-metal-to-gcp-connection/outputs.tf new file mode 100644 index 0000000..50882e5 --- /dev/null +++ b/examples/service-token-metal-to-gcp-connection/outputs.tf @@ -0,0 +1,7 @@ +output "connection_primary_details" { + value = module.equinix-fabric-connection-gcp-primary +} + +output "connection_secondary_details" { + value = var.redundancy_type == "REDUNDANT" ? module.equinix-fabric-connection-gcp-secondary : null +} diff --git a/examples/service-token-metal-to-gcp-connection/variables.tf b/examples/service-token-metal-to-gcp-connection/variables.tf new file mode 100644 index 0000000..f43be25 --- /dev/null +++ b/examples/service-token-metal-to-gcp-connection/variables.tf @@ -0,0 +1,77 @@ +variable "equinix_provider_client_id" { + type = string + description = <