Skip to content

Commit

Permalink
Routing Protocols Module (#10)
Browse files Browse the repository at this point in the history
* Add routing protocols module with example

* Remove empty version from provider statements
  • Loading branch information
thogarty authored Nov 28, 2023
1 parent 88ba16f commit fd18306
Show file tree
Hide file tree
Showing 18 changed files with 206 additions and 9 deletions.
1 change: 0 additions & 1 deletion examples/cloud-router-2-aws-connection/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ terraform {
required_providers {
equinix = {
source = "equinix/equinix"
version = ""
}
}
}
Expand Down
1 change: 0 additions & 1 deletion examples/cloud-router-2-azure-connection/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ terraform {
required_providers {
equinix = {
source = "equinix/equinix"
version = ""
}
}
}
Expand Down
1 change: 0 additions & 1 deletion examples/cloud-router-2-azure-redundant-connection/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ terraform {
required_providers {
equinix = {
source = "equinix/equinix"
version = ""
}
}
}
Expand Down
1 change: 0 additions & 1 deletion examples/cloud-router-2-gcp-connection/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ terraform {
required_providers {
equinix = {
source = "equinix/equinix"
version = ""
}
}
}
Expand Down
1 change: 0 additions & 1 deletion examples/cloud-router-2-oracle-connection/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ terraform {
required_providers {
equinix = {
source = "equinix/equinix"
version = ""
}
}
}
Expand Down
1 change: 0 additions & 1 deletion examples/cloud-router-2-port-connection/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ terraform {
required_providers {
equinix = {
source = "equinix/equinix"
version = ""
}
}
}
Expand Down
1 change: 0 additions & 1 deletion examples/cloud-router-2-service-profile-connection/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ terraform {
required_providers {
equinix = {
source = "equinix/equinix"
version = ""
}
}
}
Expand Down
1 change: 0 additions & 1 deletion examples/cloud-router-2-wan-connection/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ terraform {
required_providers {
equinix = {
source = "equinix/equinix"
version = ""
}
}
}
Expand Down
Empty file.
31 changes: 31 additions & 0 deletions examples/routing-protocols/main.tf
Original file line number Diff line number Diff line change
@@ -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
}
7 changes: 7 additions & 0 deletions examples/routing-protocols/outputs.tf
Original file line number Diff line number Diff line change
@@ -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
}
15 changes: 15 additions & 0 deletions examples/routing-protocols/terraform.tfvars.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
equinix_client_id = "<MyEquinixClientId>"
equinix_client_secret = "<MyEquinixSecret>"

connection_uuid = "<Equinix_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"
57 changes: 57 additions & 0 deletions examples/routing-protocols/variables.tf
Original file line number Diff line number Diff line change
@@ -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 = ""
}
1 change: 0 additions & 1 deletion modules/cloud-router-connection/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ terraform {
required_providers {
equinix = {
source = "equinix/equinix"
version = ""
}
}
}
Expand Down
Empty file.
41 changes: 41 additions & 0 deletions modules/routing-protocols/main.tf
Original file line number Diff line number Diff line change
@@ -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
}
}
7 changes: 7 additions & 0 deletions modules/routing-protocols/outputs.tf
Original file line number Diff line number Diff line change
@@ -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
}
48 changes: 48 additions & 0 deletions modules/routing-protocols/variables.tf
Original file line number Diff line number Diff line change
@@ -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 = ""
}

0 comments on commit fd18306

Please sign in to comment.