From fd18306669234cac81e1881b5546d4fc984d2836 Mon Sep 17 00:00:00 2001 From: thogarty <139183873+thogarty@users.noreply.github.com> Date: Mon, 27 Nov 2023 16:44:04 -0800 Subject: [PATCH] Routing Protocols Module (#10) * Add routing protocols module with example * Remove empty version from provider statements --- .../cloud-router-2-aws-connection/main.tf | 1 - .../cloud-router-2-azure-connection/main.tf | 1 - .../main.tf | 1 - .../cloud-router-2-gcp-connection/main.tf | 1 - .../cloud-router-2-oracle-connection/main.tf | 1 - .../cloud-router-2-port-connection/main.tf | 1 - .../main.tf | 1 - .../cloud-router-2-wan-connection/main.tf | 1 - examples/routing-protocols/README.md | 0 examples/routing-protocols/main.tf | 31 ++++++++++ examples/routing-protocols/outputs.tf | 7 +++ .../terraform.tfvars.example | 15 +++++ examples/routing-protocols/variables.tf | 57 +++++++++++++++++++ modules/cloud-router-connection/main.tf | 1 - modules/routing-protocols/README.md | 0 modules/routing-protocols/main.tf | 41 +++++++++++++ modules/routing-protocols/outputs.tf | 7 +++ modules/routing-protocols/variables.tf | 48 ++++++++++++++++ 18 files changed, 206 insertions(+), 9 deletions(-) create mode 100644 examples/routing-protocols/README.md create mode 100644 examples/routing-protocols/main.tf create mode 100644 examples/routing-protocols/outputs.tf create mode 100644 examples/routing-protocols/terraform.tfvars.example create mode 100644 examples/routing-protocols/variables.tf create mode 100644 modules/routing-protocols/README.md create mode 100644 modules/routing-protocols/main.tf create mode 100644 modules/routing-protocols/outputs.tf create mode 100644 modules/routing-protocols/variables.tf diff --git a/examples/cloud-router-2-aws-connection/main.tf b/examples/cloud-router-2-aws-connection/main.tf index d6979779..34b0f314 100644 --- a/examples/cloud-router-2-aws-connection/main.tf +++ b/examples/cloud-router-2-aws-connection/main.tf @@ -2,7 +2,6 @@ terraform { required_providers { equinix = { source = "equinix/equinix" - version = "" } } } diff --git a/examples/cloud-router-2-azure-connection/main.tf b/examples/cloud-router-2-azure-connection/main.tf index 5be5245e..39ecc959 100644 --- a/examples/cloud-router-2-azure-connection/main.tf +++ b/examples/cloud-router-2-azure-connection/main.tf @@ -2,7 +2,6 @@ terraform { required_providers { equinix = { source = "equinix/equinix" - version = "" } } } diff --git a/examples/cloud-router-2-azure-redundant-connection/main.tf b/examples/cloud-router-2-azure-redundant-connection/main.tf index f3b0d027..9977df73 100644 --- a/examples/cloud-router-2-azure-redundant-connection/main.tf +++ b/examples/cloud-router-2-azure-redundant-connection/main.tf @@ -2,7 +2,6 @@ terraform { required_providers { equinix = { source = "equinix/equinix" - version = "" } } } diff --git a/examples/cloud-router-2-gcp-connection/main.tf b/examples/cloud-router-2-gcp-connection/main.tf index 26bc7568..acb41595 100644 --- a/examples/cloud-router-2-gcp-connection/main.tf +++ b/examples/cloud-router-2-gcp-connection/main.tf @@ -2,7 +2,6 @@ terraform { required_providers { equinix = { source = "equinix/equinix" - version = "" } } } diff --git a/examples/cloud-router-2-oracle-connection/main.tf b/examples/cloud-router-2-oracle-connection/main.tf index f9f451b8..984aaf99 100644 --- a/examples/cloud-router-2-oracle-connection/main.tf +++ b/examples/cloud-router-2-oracle-connection/main.tf @@ -2,7 +2,6 @@ terraform { required_providers { equinix = { source = "equinix/equinix" - version = "" } } } diff --git a/examples/cloud-router-2-port-connection/main.tf b/examples/cloud-router-2-port-connection/main.tf index a8d757fc..7a593291 100644 --- a/examples/cloud-router-2-port-connection/main.tf +++ b/examples/cloud-router-2-port-connection/main.tf @@ -2,7 +2,6 @@ terraform { required_providers { equinix = { source = "equinix/equinix" - version = "" } } } diff --git a/examples/cloud-router-2-service-profile-connection/main.tf b/examples/cloud-router-2-service-profile-connection/main.tf index 4e464739..2205dc7d 100644 --- a/examples/cloud-router-2-service-profile-connection/main.tf +++ b/examples/cloud-router-2-service-profile-connection/main.tf @@ -2,7 +2,6 @@ terraform { required_providers { equinix = { source = "equinix/equinix" - version = "" } } } diff --git a/examples/cloud-router-2-wan-connection/main.tf b/examples/cloud-router-2-wan-connection/main.tf index 5c76d736..214070a4 100644 --- a/examples/cloud-router-2-wan-connection/main.tf +++ b/examples/cloud-router-2-wan-connection/main.tf @@ -2,7 +2,6 @@ terraform { required_providers { equinix = { source = "equinix/equinix" - version = "" } } } diff --git a/examples/routing-protocols/README.md b/examples/routing-protocols/README.md new file mode 100644 index 00000000..e69de29b diff --git a/examples/routing-protocols/main.tf b/examples/routing-protocols/main.tf new file mode 100644 index 00000000..c85f823a --- /dev/null +++ b/examples/routing-protocols/main.tf @@ -0,0 +1,31 @@ +terraform { + required_providers { + equinix = { + source = "equinix/equinix" + } + } +} + +provider "equinix" { + client_id = var.equinix_client_id + client_secret = var.equinix_client_secret +} + +module "routing_protocols" { + source = "../../modules/routing-protocols" + + connection_uuid = var.connection_uuid + + # Direct RP Details + direct_rp_name = var.direct_rp_name + direct_equinix_ipv4_ip = var.direct_equinix_ipv4_ip + direct_equinix_ipv6_ip = var.direct_equinix_ipv6_ip + + # BGP RP Details + bgp_rp_name = var.bgp_rp_name + bgp_customer_asn = var.bgp_customer_asn + bgp_customer_peer_ipv4 = var.bgp_customer_peer_ipv4 + bgp_enabled_ipv4 = var.bgp_enabled_ipv4 + bgp_customer_peer_ipv6 = var.bgp_customer_peer_ipv6 + bgp_enabled_ipv6 = var.bgp_enabled_ipv6 +} diff --git a/examples/routing-protocols/outputs.tf b/examples/routing-protocols/outputs.tf new file mode 100644 index 00000000..0342de89 --- /dev/null +++ b/examples/routing-protocols/outputs.tf @@ -0,0 +1,7 @@ +output "direct_rp_id" { + value = module.routing_protocols.direct_routing_protocol_id +} + +output "bgp_rp_id" { + value = module.routing_protocols.bgp_routing_protocol_id +} diff --git a/examples/routing-protocols/terraform.tfvars.example b/examples/routing-protocols/terraform.tfvars.example new file mode 100644 index 00000000..36f178ab --- /dev/null +++ b/examples/routing-protocols/terraform.tfvars.example @@ -0,0 +1,15 @@ +equinix_client_id = "" +equinix_client_secret = "" + +connection_uuid = "" + +direct_rp_name = "DIRECT_RP" +direct_equinix_ipv4_ip = "190.1.1.1/30" +direct_equinix_ipv6_ip = "190::1:1/126" + +bgp_rp_name = "BGP_RP" +bgp_customer_peer_ipv4 = "190.1.1.2" +bgp_customer_peer_ipv6 = "190::1:2" +bgp_enabled_ipv4 = true +bgp_enabled_ipv6 = true +bgp_customer_asn = "100" diff --git a/examples/routing-protocols/variables.tf b/examples/routing-protocols/variables.tf new file mode 100644 index 00000000..54854e37 --- /dev/null +++ b/examples/routing-protocols/variables.tf @@ -0,0 +1,57 @@ +variable "equinix_client_id" { + description = "Equinix client ID (consumer key), obtained after registering app in the developer platform" + type = string +} +variable "equinix_client_secret" { + description = "Equinix client secret ID (consumer secret), obtained after registering app in the developer platform" + type = string +} + +variable "connection_uuid" { + description = "Equinix Connection UUID to Apply the Routing Protocols to" + type = string +} +variable "direct_rp_name" { + description = "Name of the Direct Routing Protocol" + type = string +} +variable "direct_equinix_ipv4_ip" { + description = "IPv4 Address for Direct Routing Protocol" + type = string +} +variable "direct_equinix_ipv6_ip" { + description = "IPv6 Address for Direct Routing Protocol" + type = string +} + + +variable "bgp_rp_name" { + description = "Name of the BGP Routing Protocol" + type = string + default = "" +} +variable "bgp_customer_peer_ipv4" { + description = "Customer Peering IPv4 Address for BGP Routing Protocol" + type = string + default = "" +} +variable "bgp_customer_peer_ipv6" { + description = "Customer Peering IPv6 Address for BGP Routing Protocol" + type = string + default = "" +} +variable "bgp_enabled_ipv4" { + description = "Boolean Enable Flag for IPv4 Peering on BGP Routing Protocol" + type = bool + default = true +} +variable "bgp_enabled_ipv6" { + description = "Boolean Enable Flag for IPv6 Peering on BGP Routing Protocol" + type = bool + default = true +} +variable "bgp_customer_asn" { + description = "Customer ASN for BGP Routing Protocol" + type = string + default = "" +} diff --git a/modules/cloud-router-connection/main.tf b/modules/cloud-router-connection/main.tf index ae35376d..2d583a85 100644 --- a/modules/cloud-router-connection/main.tf +++ b/modules/cloud-router-connection/main.tf @@ -2,7 +2,6 @@ terraform { required_providers { equinix = { source = "equinix/equinix" - version = "" } } } diff --git a/modules/routing-protocols/README.md b/modules/routing-protocols/README.md new file mode 100644 index 00000000..e69de29b diff --git a/modules/routing-protocols/main.tf b/modules/routing-protocols/main.tf new file mode 100644 index 00000000..8579dacb --- /dev/null +++ b/modules/routing-protocols/main.tf @@ -0,0 +1,41 @@ +terraform { + required_providers { + equinix = { + source = "equinix/equinix" + } + } +} + +resource "equinix_fabric_routing_protocol" "direct" { + connection_uuid = var.connection_uuid + name = var.direct_rp_name + type = "DIRECT" + direct_ipv4 { + equinix_iface_ip = var.direct_equinix_ipv4_ip + } + direct_ipv6 { + equinix_iface_ip = var.direct_equinix_ipv6_ip + } +} + +resource "equinix_fabric_routing_protocol" "bgp" { + count = var.bgp_rp_name != "" ? 1 : 0 + depends_on = [ + equinix_fabric_routing_protocol.direct + ] + + connection_uuid = var.connection_uuid + name = var.bgp_rp_name + type = "BGP" + + customer_asn = var.bgp_customer_asn + + bgp_ipv4 { + enabled = var.bgp_enabled_ipv4 + customer_peer_ip = var.bgp_customer_peer_ipv4 + } + bgp_ipv6 { + enabled = var.bgp_enabled_ipv6 + customer_peer_ip = var.bgp_customer_peer_ipv6 + } +} diff --git a/modules/routing-protocols/outputs.tf b/modules/routing-protocols/outputs.tf new file mode 100644 index 00000000..cc0205b0 --- /dev/null +++ b/modules/routing-protocols/outputs.tf @@ -0,0 +1,7 @@ +output "direct_routing_protocol_id" { + value = equinix_fabric_routing_protocol.direct.id +} + +output "bgp_routing_protocol_id" { + value = var.bgp_rp_name != "" ? equinix_fabric_routing_protocol.bgp[0].id : null +} diff --git a/modules/routing-protocols/variables.tf b/modules/routing-protocols/variables.tf new file mode 100644 index 00000000..4e725181 --- /dev/null +++ b/modules/routing-protocols/variables.tf @@ -0,0 +1,48 @@ +variable "connection_uuid" { + description = "Equinix Connection UUID to Apply the Routing Protocols to" + type = string +} +variable "direct_rp_name" { + description = "Name of the Direct Routing Protocol" + type = string +} +variable "direct_equinix_ipv4_ip" { + description = "IPv4 Address for Direct Routing Protocol" + type = string +} +variable "direct_equinix_ipv6_ip" { + description = "IPv6 Address for Direct Routing Protocol" + type = string +} + + +variable "bgp_rp_name" { + description = "Name of the BGP Routing Protocol" + type = string + default = "" +} +variable "bgp_customer_peer_ipv4" { + description = "Customer Peering IPv4 Address for BGP Routing Protocol" + type = string + default = "" +} +variable "bgp_customer_peer_ipv6" { + description = "Customer Peering IPv6 Address for BGP Routing Protocol" + type = string + default = "" +} +variable "bgp_enabled_ipv4" { + description = "Boolean Enable Flag for IPv4 Peering on BGP Routing Protocol" + type = bool + default = true +} +variable "bgp_enabled_ipv6" { + description = "Boolean Enable Flag for IPv6 Peering on BGP Routing Protocol" + type = bool + default = true +} +variable "bgp_customer_asn" { + description = "Customer ASN for BGP Routing Protocol" + type = string + default = "" +}