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: Add FCR 2 Metal Redundant Connection Example #108

Merged
merged 10 commits into from
Aug 2, 2024
13 changes: 13 additions & 0 deletions examples/cloud-router-2-metal-nimf-redundant-connection/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Fabric Cloud Router to Equinix Metal Redundant Connection

This example shows how to leverage the [Fabric Cloud Router Connection Module](../../modules/cloud-router-connection/README.md)
to create a Fabric Connection from a Fabric Cloud Router to Equinix Metal with two connections. A primary and secondary connection.

It leverages the Equinix Terraform Provider, and the Fabric Cloud Router 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) -->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These don't belong. We're not leveraging them anymore. Please remove.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clarity on comment: we don't need these boundary declarations anymore <!-- Begin Example Usage (Do not edit contents) -->. They were for the previous shell script methods but now that we just use terraform-docs then we won't have any need for these. Hope that clears it up.

Copy link
Collaborator Author

@d-bhola d-bhola Aug 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed with commit

<!-- End Example Usage -->
73 changes: 73 additions & 0 deletions examples/cloud-router-2-metal-nimf-redundant-connection/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
provider "equinix" {
Copy link
Collaborator

@srushti-patl srushti-patl Aug 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add extra spaces between all code blocks

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_vlan" "vlan-server-1" {
description = "${var.metal_connection_metro} VLAN Server 2 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, equinix_metal_vlan.vlan-server-1.vxlan]
contact_email = var.metal_contact_email
}

module "cloud_router_2_metal_connection" {
source = "../../modules/cloud-router-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_fcr_uuid = var.aside_fcr_uuid

#Zside
zside_ap_type = var.zside_ap_type
zside_ap_authentication_key = equinix_metal_connection.metal-connection.authorization_code

#Secondary-Connection
secondary_connection_name = var.secondary_connection_name
secondary_bandwidth = var.secondary_bandwidth
}

module "primary_connection_routing_protocols" {
depends_on = [module.cloud_router_2_metal_connection]
source = "../../modules/cloud-router-routing-protocols"

connection_uuid = module.cloud_router_2_metal_connection.primary_connection_id

# Direct RP Details
direct_rp_name = var.primary_direct_rp_name
direct_equinix_ipv4_ip = var.primary_direct_equinix_ipv4_ip
}

module "secondary_connection_routing_protocols" {
depends_on = [module.cloud_router_2_metal_connection]
source = "../../modules/cloud-router-routing-protocols"

connection_uuid = module.cloud_router_2_metal_connection.secondary_connection_id

# Direct RP Details
direct_rp_name = var.secondary_direct_rp_name
direct_equinix_ipv4_ip = var.secondary_direct_equinix_ipv4_ip
}
15 changes: 15 additions & 0 deletions examples/cloud-router-2-metal-nimf-redundant-connection/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
output "metal_vlan_id" {
value = equinix_metal_vlan.vlan-server.id
}
output "metal_connection_id" {
value = equinix_metal_connection.metal-connection.id
}
output "cloud_router_metal_primary_connection_id" {
value = module.cloud_router_2_metal_connection.primary_connection_id
}
output "primary_connection_cloud_router_routing_protocol_id" {
value = module.primary_connection_routing_protocols.direct_routing_protocol_id
}
output "secondary_connection_cloud_router_routing_protocol_id" {
value = module.secondary_connection_routing_protocols.direct_routing_protocol_id
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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 = "redundant"
metal_connection_speed = "50Mbps"
metal_connection_type = "shared_port_vlan"
metal_contact_email = "tfacc@example.com"

connection_name = "FCR_2_Metal_DIGP"
connection_type = "IP_VC"
notifications_type = "ALL"
notifications_emails = ["example@equinix.com","test1@equinix.com"]
purchase_order_number = "1-323292"
bandwidth = "50"
project_id = "<Fabric_Project_ID>"
zside_ap_type = "METAL_NETWORK"
primary_direct_rp_name = "pri_direct_rp"
secondary_direct_rp_name = "sec_direct_rp"
primary_direct_equinix_ipv4_ip = "190.1.1.25/30"
secondary_direct_equinix_ipv4_ip = "190.1.1.9/30"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would reorder the example variables to match the ordering present in variables.tf files.

Copy link
Collaborator Author

@d-bhola d-bhola Aug 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed with commit

secondary_connection_name = "fcr_2_metal_sec"
secondary_bandwidth = "50"
aside_fcr_uuid = "<Primary Fabric Cloud router UUID>"
108 changes: 108 additions & 0 deletions examples/cloud-router-2-metal-nimf-redundant-connection/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
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
}
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
}
#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
default = ""
}
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 "bandwidth" {
description = "Connection bandwidth in Mbps"
type = number
}
variable "purchase_order_number" {
description = "Purchase order number"
type = string
default = ""
}
variable "project_id" {
description = "Equinix Fabric Project Id"
type = string
}
variable "aside_fcr_uuid" {
description = "Equinix-assigned Primary Fabric Cloud Router identifier"
type = string
}
variable "zside_ap_type" {
description = "Access point type - COLO, VD, VG, SP, IGW, SUBNET, GW"
type = string
default = "SP"
}
variable "secondary_connection_name" {
description = "Secondary connection name. An alpha-numeric 24 characters string which can include only hyphens and underscores"
type = string
}
variable "secondary_bandwidth" {
description = "Secondary connection bandwidth in Mbps"
type = number
}
variable "primary_direct_rp_name" {
description = "Name of the Direct Routing Protocol"
type = string
}
variable "primary_direct_equinix_ipv4_ip" {
description = "IPv4 Address for Direct Routing Protocol"
type = string
}
variable "secondary_direct_rp_name" {
description = "Name of the Direct Routing Protocol for Secondary Connection"
type = string
}
variable "secondary_direct_equinix_ipv4_ip" {
description = "IPv4 Address for Direct Routing Protocol for Secondary Connection"
type = string
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
terraform {
required_version = ">= 1.5.4"
required_providers {
equinix = {
source = "equinix/equinix"
version = ">= 1.36.4"
}
}
}
Loading