Skip to content

Commit

Permalink
feat: Adding Port Term Based Connections examples (#167)
Browse files Browse the repository at this point in the history
* feat: Adding Port Term Based Connections examples

* feat: Updating port modules to support term based examples

* fix: Updating Equinix Provider Version

* fix: Updating term_length default value to zero
  • Loading branch information
srushti-patl authored Feb 24, 2025
1 parent 216e674 commit 2eec22c
Show file tree
Hide file tree
Showing 15 changed files with 303 additions and 2 deletions.
13 changes: 13 additions & 0 deletions examples/port-2-network-term-based-connection/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Fabric Port to Fabric Network Term Based Connection

This example shows how to leverage the [Fabric Port Connection Module](https://registry.terraform.io/modules/equinix/fabric/equinix/latest/submodules/port-connection)
to create a Fabric Term Based Connection from a Fabric Port to Fabric Network.

It leverages the Equinix Terraform Provider,and the Fabric Port 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_TF_DOCS -->
<!-- END_TF_DOCS -->
24 changes: 24 additions & 0 deletions examples/port-2-network-term-based-connection/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
provider "equinix" {
client_id = var.equinix_client_id
client_secret = var.equinix_client_secret
}

module "create_port_2_network_connection" {
source = "../../modules/port-connection"

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

# A-side
aside_port_name = var.aside_port_name
aside_vlan_tag = var.aside_vlan_tag

# Z-side
zside_ap_type = var.zside_ap_type
zside_network_uuid = var.zside_network_uuid
}
8 changes: 8 additions & 0 deletions examples/port-2-network-term-based-connection/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
output "port_connection" {
value = module.create_port_2_network_connection.primary_connection
sensitive = true
}

output "port_connection_id" {
value = module.create_port_2_network_connection.primary_connection_id
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
equinix_client_id = "MyEquinixClientId"
equinix_client_secret = "MyEquinixSecret"

connection_name = "Port2Port"
connection_type = "EVPL_VC"
notifications_type = "ALL"
notifications_emails = ["example@equinix.com", "test1@equinix.com"]
bandwidth = 50
purchase_order_number = "1-323292"
term_length = 12
aside_port_name = "ops-user100-CX-SV5-NL-Qinq-STD-1G-SEC-JP-190"
aside_location = "DC"
aside_vlan_tag = "1976"
zside_ap_type = "NETWORK"
zside_network_uuid = "0a7c6e03-5d9a-4dfd-bb46-a6fa3fbde231"
66 changes: 66 additions & 0 deletions examples/port-2-network-term-based-connection/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
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 "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 "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 "term_length" {
description = "Order Term Length"
type = number
default = 1
}
variable "aside_port_name" {
description = "Equinix A-Side Port Name"
type = string
}
variable "aside_location" {
description = "Aside metro code"
type = string
}
variable "aside_vlan_tag" {
description = "Vlan Tag information, outer vlanSTag for QINQ connections"
type = string
}
variable "aside_vlan_inner_tag" {
description = "Vlan Inner Tag information, inner vlanCTag for QINQ connections"
type = string
default = ""
}
variable "zside_ap_type" {
description = "Access point type - COLO, VD, VG, SP, IGW, SUBNET, GW"
type = string
}
variable "zside_network_uuid" {
description = "Equinix Network UUID"
type = string
}
9 changes: 9 additions & 0 deletions examples/port-2-network-term-based-connection/versions.tf
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 = ">= 3.2.0"
}
}
}
13 changes: 13 additions & 0 deletions examples/port-2-port-term-based-connection/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Fabric Port to Fabric Port Term Based Connection

This example shows how to leverage the [Fabric Port Connection Module](https://registry.terraform.io/modules/equinix/fabric/equinix/latest/submodules/port-connection)
to create a Fabric Term Based Connection from a Fabric Port to Fabric Port.

It leverages the Equinix Terraform Provider, and the Fabric Port 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_TF_DOCS -->
<!-- END_TF_DOCS -->
27 changes: 27 additions & 0 deletions examples/port-2-port-term-based-connection/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
provider "equinix" {
client_id = var.equinix_client_id
client_secret = var.equinix_client_secret
}

module "create_port_2_port_connection" {
source = "../../modules/port-connection"

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

# A-side
aside_port_name = var.aside_port_name
aside_vlan_tag = var.aside_vlan_tag
aside_location = var.aside_location

# Z-side
zside_ap_type = var.zside_ap_type
zside_port_name = var.zside_port_name
zside_vlan_tag = var.zside_vlan_tag
zside_location = var.zside_location
}
8 changes: 8 additions & 0 deletions examples/port-2-port-term-based-connection/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
output "port_connection" {
value = module.create_port_2_port_connection.primary_connection
sensitive = true
}

output "port_connection_id" {
value = module.create_port_2_port_connection.primary_connection_id
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
equinix_client_id = "MyEquinixClientId"
equinix_client_secret = "MyEquinixSecret"

connection_name = "Port2Port"
connection_type = "EVPL_VC"
notifications_type = "ALL"
notifications_emails = ["example@equinix.com", "test1@equinix.com"]
bandwidth = 50
purchase_order_number = "1-323292"
term_length = 12
aside_port_name = "ops-user100-CX-SV5-NL-Qinq-STD-1G-SEC-JP-190"
aside_location = "DC"
aside_vlan_tag = "1976"
zside_ap_type = "COLO"
zside_port_name = "ops-user100-CX-SV1-NL-Qinq-STD-1G-PRI-NK-349"
zside_vlan_tag = "3711"
zside_location = "SV"
74 changes: 74 additions & 0 deletions examples/port-2-port-term-based-connection/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
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 "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 "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 "term_length" {
description = "Order Term Length"
type = number
default = 1
}
variable "aside_port_name" {
description = "Equinix A-Side Port Name"
type = string
}
variable "aside_location" {
description = "Aside metro code"
type = string
}
variable "aside_vlan_tag" {
description = "Vlan Tag information, outer vlanSTag for QINQ connections"
type = string
}
variable "aside_vlan_inner_tag" {
description = "Vlan Inner Tag information, inner vlanCTag for QINQ connections"
type = string
default = ""
}
variable "zside_ap_type" {
description = "Access point type - COLO, VD, VG, SP, IGW, SUBNET, GW"
type = string
}
variable "zside_location" {
description = "Zside metro code"
type = string
}
variable "zside_port_name" {
description = "Equinix Port Name"
type = string
}
variable "zside_vlan_tag" {
description = "Vlan Tag information, outer vlanSTag for QINQ connections"
type = string
}
9 changes: 9 additions & 0 deletions examples/port-2-port-term-based-connection/versions.tf
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 = ">= 3.2.0"
}
}
}
8 changes: 8 additions & 0 deletions modules/port-connection/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ resource "equinix_fabric_connection" "primary_port_connection" {
redundancy { priority = "PRIMARY" }
order {
purchase_order_number = var.purchase_order_number != "" ? var.purchase_order_number : null
term_length = var.term_length >= 1 ? var.term_length: null
}

additional_info = var.additional_info != [] ? var.additional_info : null
Expand All @@ -54,6 +55,9 @@ resource "equinix_fabric_connection" "primary_port_connection" {
port {
uuid = data.equinix_fabric_ports.aside_port.data.0.uuid
}
location {
metro_code = var.aside_location != "" ? var.aside_location : null
}
link_protocol {
type = one(data.equinix_fabric_ports.aside_port.data.0.encapsulation).type
vlan_tag = one(data.equinix_fabric_ports.aside_port.data.0.encapsulation).type == "DOT1Q" ? var.aside_vlan_tag : null
Expand Down Expand Up @@ -151,6 +155,7 @@ resource "equinix_fabric_connection" "secondary_port_connection" {
}
order {
purchase_order_number = var.purchase_order_number != "" ? var.purchase_order_number : null
term_length = var.term_length >= 1 ? var.term_length: null
}

additional_info = var.additional_info != [] ? var.additional_info : null
Expand All @@ -161,6 +166,9 @@ resource "equinix_fabric_connection" "secondary_port_connection" {
port {
uuid = data.equinix_fabric_ports.aside_secondary_port[0].data.0.uuid
}
location {
metro_code = var.aside_location != "" ? var.aside_location : null
}
link_protocol {
type = one(data.equinix_fabric_ports.aside_secondary_port[0].data.0.encapsulation).type
vlan_tag = one(data.equinix_fabric_ports.aside_secondary_port[0].data.0.encapsulation).type == "DOT1Q" ? var.aside_secondary_vlan_tag : null
Expand Down
12 changes: 11 additions & 1 deletion modules/port-connection/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ variable "purchase_order_number" {
type = string
default = ""
}
variable "term_length" {
description = "Order Term Length"
type = number
default = 0
}
variable "aside_port_name" {
description = "Equinix A-Side Port Name; your tagging must match the encapsulation type of the port (DOT1Q or QINQ)"
type = string
Expand All @@ -48,6 +53,11 @@ variable "aside_secondary_port_name" {
type = string
default = ""
}
variable "aside_location" {
description = "Aside metro code"
type = string
default = ""
}
variable "aside_vlan_tag" {
description = "VLan Tag information for DOT1Q connections, and the outer VLan tag for QINQ connections)"
type = string
Expand Down Expand Up @@ -83,7 +93,7 @@ variable "zside_ap_profile_type" {
default = ""
}
variable "zside_location" {
description = "Access point metro code"
description = "Zside metro code"
type = string
default = ""
}
Expand Down
2 changes: 1 addition & 1 deletion modules/port-connection/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ terraform {
required_providers {
equinix = {
source = "equinix/equinix"
version = ">= 2.9.0"
version = ">= 3.2.0"
}
}
}

0 comments on commit 2eec22c

Please sign in to comment.