Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Adding NIMF Metal 2 Google and Metal 2 IBM2 examples #76

Merged
merged 2 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions examples/metal-nimf-2-google-connection/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Metal to Google Service Profile Connection Example

This example shows how to leverage the [Metal Connection Module](../../modules/metalconnection/README.md)
to create a Fabric Connection from Equinix Metal to Google Service Profile.

It leverages the Equinix Terraform Provider and the Metal Connection
Module to setup the connection based on the parameters you have provided to this example; or based on the pattern
you see used in this example it will allow you to create a more specific use case for your own needs.

See example usage below for details on how to use this example.

<!-- Begin Example Usage (Do not edit contents) -->
<!-- End Example Usage -->
74 changes: 74 additions & 0 deletions examples/metal-nimf-2-google-connection/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
provider "equinix" {
client_id = var.equinix_client_id
client_secret = var.equinix_client_secret
auth_token = var.metal_auth_token
}
provider "google" {
region = var.google_region
project = var.google_project_id
zone = var.google_zone
credentials = var.google_credentials_path
}

resource "equinix_metal_vlan" "vlan-server" {
description = "${var.metal_connection_metro} VLAN Server 1 to Cloud"
metro = var.metal_connection_metro
project_id = var.metal_project_id
}

resource "equinix_metal_connection" "metal-connection" {
name = var.metal_connection_name
redundancy = var.metal_connection_redundancy
speed = var.metal_connection_speed
type = var.metal_connection_type
project_id = var.metal_project_id
metro = var.metal_connection_metro
vlans = [equinix_metal_vlan.vlan-server.vxlan]
contact_email = var.metal_contact_email
}

resource "google_compute_network" "metal-nimf-google" {
project = var.google_project_id
name = var.google_network_name
mtu = var.google_network_mtu
auto_create_subnetworks = var.google_network_auto_create_subnetwork
}

resource "google_compute_router" "metal-nimf-google" {
name = var.google_router_name
network = google_compute_network.metal-nimf-google.name
bgp {
asn = var.google_router_bgp_asn
}
}

resource "google_compute_interconnect_attachment" "metal-nimf-google" {
name = var.google_interconnect_name
type = var.google_interconnect_type
router = google_compute_router.metal-nimf-google.id
region = var.google_region
edge_availability_domain = var.google_interconnect_edge_availability_domain
}

module "metal_2_google_connection" {
source = "../../modules/metal-connection"

connection_name = var.connection_name
connection_type = var.connection_type
notifications_type = var.notifications_type
notifications_emails = var.notifications_emails
project_id = var.project_id
bandwidth = var.bandwidth
purchase_order_number = var.purchase_order_number

#Aside
aside_ap_authentication_key = equinix_metal_connection.metal-connection.authorization_code

#Zside
zside_ap_type = var.zside_ap_type
zside_ap_authentication_key = google_compute_interconnect_attachment.metal-nimf-google.pairing_key
zside_ap_profile_type = var.zside_ap_profile_type
zside_location = var.zside_location
zside_seller_region = var.google_region
zside_fabric_sp_name = var.zside_fabric_sp_name
}
18 changes: 18 additions & 0 deletions examples/metal-nimf-2-google-connection/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
output "metal_vlan_id" {
value = equinix_metal_vlan.vlan-server.id
}
output "metal_connection_id" {
value = equinix_metal_connection.metal-connection.id
}
output "GCP_Network_Id" {
value = google_compute_network.metal-nimf-google.id
}
output "GCP_Router_Id" {
value = google_compute_router.metal-nimf-google.id
}
output "GCP_Interconnect_Id" {
value = google_compute_interconnect_attachment.metal-nimf-google.id
}
output "Metal_Google_Connection_Id" {
value = module.metal_2_google_connection.primary_connection_id
}
37 changes: 37 additions & 0 deletions examples/metal-nimf-2-google-connection/terraform.tfvars.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
equinix_client_id = "<MyEquinixClientId>"
equinix_client_secret = "<MyEquinixSecret>"
metal_auth_token = "<Metal_Auth_Token>"

metal_connection_metro = "sv"
metal_project_id = "<Metal_Project_ID>"
metal_connection_name = "Metal-NIMF-connection"
metal_connection_redundancy = "primary"
metal_connection_speed = "50Mbps"
metal_connection_type = "shared_port_vlan"
metal_contact_email = "tfacc@example.com"

connection_name = "Metal_2_Google"
connection_type = "EVPL_VC"
notifications_type = "ALL"
notifications_emails = ["example@equinix.com"]
bandwidth = 50
purchase_order_number = "1-323292"
project_id = "<Project_ID>"
zside_ap_type = "SP"
zside_peering_type = "PRIVATE"
zside_ap_profile_type = "L2_PROFILE"
zside_location = "SV"
zside_fabric_sp_name = "Google Cloud Partner Interconnect Zone 1"

google_project_id = "<GCP Project ID>"
google_region = "us-west1"
google_zone = "us-west1-a"
google_credentials_path = "<GCP KEY FILE NAME>"
google_network_name = "tf-test-network"
google_network_mtu = "1460"
google_network_auto_create_subnetwork = true
google_router_name = "tf-test-router"
google_router_bgp_asn = "16550"
google_interconnect_name = "tf-test-interconnect"
google_interconnect_type = "PARTNER"
google_interconnect_edge_availability_domain = "AVAILABILITY_DOMAIN_1"
140 changes: 140 additions & 0 deletions examples/metal-nimf-2-google-connection/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
variable "equinix_client_id" {
description = "Equinix client ID (consumer key), obtained after registering app in the developer platform"
type = string
sensitive = true
}
variable "equinix_client_secret" {
description = "Equinix client secret ID (consumer secret), obtained after registering app in the developer platform"
type = string
sensitive = true
}
#Metal Connection
variable "metal_auth_token" {
description = "Equinix Metal Authentication API Token"
type = string
sensitive = true
}
variable "metal_connection_metro" {
description = "Metro where the connection will be created"
type = string
}
variable "metal_project_id" {
description = "Metal Project Name"
type = string
}
variable "metal_connection_name" {
description = "Metal Connection Name"
type = string
}
variable "metal_connection_redundancy" {
description = "Metal Connection redundancy - redundant or primary"
type = string
}
variable "metal_connection_speed" {
description = "Metal Connection speed - one of 50Mbps, 200Mbps, 500Mbps, 1Gbps, 2Gbps, 5Gbps, 10Gbps"
type = string
}
variable "metal_connection_type" {
description = "Metal Connection type - dedicated , shared or shared_port_vlan"
type = string
}
variable "metal_contact_email" {
description = "Preferred email used for communication"
type = string
}
#Google Provider
variable "google_region" {
description = "The Google region to manage resources in"
type = string
}
variable "google_project_id" {
description = "The default Google Project Id to manage resources in"
type = string
}
variable "google_zone" {
description = "The default Google Zone to manage resources in"
type = string
}
variable "google_credentials_path" {
description = "Path to the contents of a service account key file in JSON format"
type = string
}
variable "google_network_name" {
description = "The Google Network Name"
type = string
}
variable "google_network_mtu" {
description = "The Google Network Maximum Transmission Unit in bytes"
type = string
}
variable "google_network_auto_create_subnetwork" {
description = "When set to true, the network is created in auto subnet mode"
type = bool
}
variable "google_router_name" {
description = "The Google Router Name"
type = string
}
variable "google_router_bgp_asn" {
description = "The Google Router Local BGP Autonomous System Number (ASN)"
type = string
}
variable "google_interconnect_name" {
description = "The Google Interconnect Name"
type = string
}
variable "google_interconnect_type" {
description = "The Google Interconnect Type"
type = string
}
variable "google_interconnect_edge_availability_domain" {
description = "The Google Interconnect Edge Availability Domain"
type = string
}
#Fabric Connection
variable "connection_name" {
description = "Connection name. An alpha-numeric 24 characters string which can include only hyphens and underscores"
type = string
}
variable "connection_type" {
description = "Defines the connection type like VG_VC, EVPL_VC, EPL_VC, EC_VC, IP_VC, ACCESS_EPL_VC"
type = string
}
variable "bandwidth" {
description = "Connection bandwidth in Mbps"
type = number
}
variable "notifications_type" {
description = "Notification Type - ALL is the only type currently supported"
type = string
default = "ALL"
}
variable "notifications_emails" {
description = "Array of contact emails"
type = list(string)
}
variable "purchase_order_number" {
description = "Purchase order number"
type = string
default = ""
}
variable "project_id" {
description = "Equinix Fabric Project Id"
type = string
}
variable "zside_ap_type" {
description = "Access point type - COLO, VD, VG, SP, IGW, SUBNET, GW"
type = string
}
variable "zside_ap_profile_type" {
description = "Service profile type - L2_PROFILE, L3_PROFILE, ECIA_PROFILE, ECMC_PROFILE"
type = string
}
variable "zside_location" {
description = "Access point metro code"
type = string
}
variable "zside_fabric_sp_name" {
description = "Equinix Service Profile Name"
type = string
}
13 changes: 13 additions & 0 deletions examples/metal-nimf-2-google-connection/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
terraform {
required_version = ">= 1.5.4"
required_providers {
equinix = {
source = "equinix/equinix"
version = ">= 1.34.0"
}
google = {
source = "hashicorp/google"
version = "5.17.0"
}
}
}
13 changes: 13 additions & 0 deletions examples/metal-nimf-2-ibm2-connection/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Metal to IBM2 Service Profile Connection Example

This example shows how to leverage the [Metal Connection Module](../../modules/metalconnection/README.md)
to create a Fabric Connection from Equinix Metal to IBM2 Service Profile.

It leverages the Equinix Terraform Provider and the Metal Connection
Module to setup the connection based on the parameters you have provided to this example; or based on the pattern
you see used in this example it will allow you to create a more specific use case for your own needs.

See example usage below for details on how to use this example.

<!-- Begin Example Usage (Do not edit contents) -->
<!-- End Example Usage -->
46 changes: 46 additions & 0 deletions examples/metal-nimf-2-ibm2-connection/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
provider "equinix" {
client_id = var.equinix_client_id
client_secret = var.equinix_client_secret
auth_token = var.metal_auth_token
}

resource "equinix_metal_vlan" "vlan-server" {
description = "${var.metal_connection_metro} VLAN Server 1 to Cloud"
metro = var.metal_connection_metro
project_id = var.metal_project_id
}

resource "equinix_metal_connection" "metal-connection" {
name = var.metal_connection_name
redundancy = var.metal_connection_redundancy
speed = var.metal_connection_speed
type = var.metal_connection_type
project_id = var.metal_project_id
metro = var.metal_connection_metro
vlans = [equinix_metal_vlan.vlan-server.vxlan]
contact_email = var.metal_contact_email
}

module "metal_2_google_connection" {
source = "../../modules/metal-connection"

connection_name = var.connection_name
connection_type = var.connection_type
notifications_type = var.notifications_type
notifications_emails = var.notifications_emails
project_id = var.project_id
bandwidth = var.bandwidth
purchase_order_number = var.purchase_order_number

#Aside
aside_ap_authentication_key = equinix_metal_connection.metal-connection.authorization_code

#Zside
zside_ap_type = var.zside_ap_type
zside_ap_authentication_key = var.zside_ap_authentication_key
zside_ap_profile_type = var.zside_ap_profile_type
zside_location = var.zside_location
zside_seller_region = var.zside_seller_region
zside_fabric_sp_name = var.zside_fabric_sp_name
additional_info = var.additional_info
}
9 changes: 9 additions & 0 deletions examples/metal-nimf-2-ibm2-connection/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
output "metal_vlan_id" {
value = equinix_metal_vlan.vlan-server.id
}
output "metal_connection_id" {
value = equinix_metal_connection.metal-connection.id
}
output "Metal_IBM2_Connection_Id" {
value = module.metal_2_google_connection.primary_connection_id
}
26 changes: 26 additions & 0 deletions examples/metal-nimf-2-ibm2-connection/terraform.tfvars.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
equinix_client_id = "<MyEquinixClientId>"
equinix_client_secret = "<MyEquinixSecret>"
metal_auth_token = "<Metal_Auth_Token>"

metal_connection_metro = "sv"
metal_project_id = "<Metal_Project_ID>"
metal_connection_name = "Metal-NIMF-connection"
metal_connection_redundancy = "primary"
metal_connection_speed = "50Mbps"
metal_connection_type = "shared_port_vlan"
metal_contact_email = "tfacc@example.com"

connection_name = "Metal_2_IBM2"
connection_type = "EVPL_VC"
notifications_type = "ALL"
notifications_emails = ["example@equinix.com"]
bandwidth = 50
purchase_order_number = "1-323292"
project_id = "<Project_ID>"
zside_ap_type = "SP"
zside_ap_authentication_key = "<IBM2 Service Key>",
zside_ap_profile_type = "L2_PROFILE"
zside_location = "SV"
zside_fabric_sp_name = "IBM Cloud Direct Link 2"
zside_seller_region = "San Jose 2"
additional_info = [ {"key" : "ASN", "value": 1234 }]
Loading
Loading