Skip to content

Commit

Permalink
CXF-83186 Integrating AWS cloud provider with fabric examples (#24)
Browse files Browse the repository at this point in the history
* CXF-83186 Integrating AWS cloud provider with fabric examples

* CXF-83184 Updating provider version and renaming example folder
  • Loading branch information
srushti-patl authored Jan 30, 2024
1 parent be33e58 commit 8339eb2
Show file tree
Hide file tree
Showing 15 changed files with 309 additions and 12 deletions.
45 changes: 44 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,11 @@ provider "equinix" {
client_id = var.equinix_client_id
client_secret = var.equinix_client_secret
}

provider "aws" {
access_key = var.additional_info[0]["value"]
secret_key = var.additional_info[1]["value"]
region = var.zside_seller_region
}
module "cloud_router_aws_connection" {
source = "../../modules/cloud-router-connection"

Expand All @@ -26,3 +30,42 @@ module "cloud_router_aws_connection" {
zside_seller_region = var.zside_seller_region
zside_fabric_sp_name = var.zside_fabric_sp_name
}

data "aws_dx_connection" "connection_id" {
depends_on = [
module.cloud_router_aws_connection
]
name = var.connection_name
}

resource "aws_vpc" "example" {
depends_on = [
module.cloud_router_aws_connection
]
cidr_block = var.aws_vpc_cidr_block
}

resource "aws_vpn_gateway" "example" {
depends_on = [
module.cloud_router_aws_connection
]
vpc_id = aws_vpc.example.id
}

resource "aws_dx_private_virtual_interface" "example" {
depends_on = [
module.cloud_router_aws_connection,
aws_vpn_gateway.example,
aws_vpc.example
]
connection_id = data.aws_dx_connection.connection_id.id
name = var.aws_vif_name
vlan = var.aws_vif_vlan
address_family = var.aws_vif_address_family
bgp_asn = var.aws_vif_bgp_asn
amazon_address = var.aws_vif_amazon_address
customer_address = var.aws_vif_customer_address
bgp_auth_key = var.aws_vif_bgp_auth_key
vpn_gateway_id = aws_vpn_gateway.example.id
}

10 changes: 10 additions & 0 deletions examples/cloud-router-2-aws-connection/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
output "module_output" {
value = module.cloud_router_aws_connection.primary_connection_id
}
output "aws_vpc_id" {
value = aws_vpc.example.id
}
output "aws_vpn_gateway_id" {
value = aws_vpn_gateway.example.id
}
output "aws_interface_id" {
value = aws_dx_private_virtual_interface.example.id
}

Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,12 @@ additional_info = [
{ key = "accessKey", value = "<aws_access_key>" },
{ key = "secretKey", value = "<aws_secret_key>" }
]

aws_vpc_cidr_block = "10.255.255.0/28"
aws_vif_name = "port2aws"
aws_vif_vlan = "320"
aws_vif_address_family = "ipv4"
aws_vif_bgp_asn = 64999
aws_vif_amazon_address = "169.254.0.1/30"
aws_vif_customer_address = "169.254.0.2/30"
aws_vif_bgp_auth_key = "secret"
37 changes: 36 additions & 1 deletion examples/cloud-router-2-aws-connection/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,44 @@ variable "zside_seller_region" {
type = string
default = ""
}

variable "additional_info" {
description = "Additional parameters required for some service profiles. It should be a list of maps containing 'key' and 'value e.g. `[{ key='asn' value = '65000'}, { key='ip' value = '192.168.0.1'}]`"
type = list(object({ key = string, value = string }))
default = []
}
variable "aws_vpc_cidr_block" {
description = "The IPv4 CIDR block for the VPC"
type = string
}
variable "aws_vif_name" {
description = "The name for the virtual interface"
type = string
}
variable "aws_vif_vlan" {
description = " The VLAN ID"
type = string
}
variable "aws_vif_address_family" {
description = "The address family for the BGP peer. ipv4 or ipv6"
type = string
}
variable "aws_vif_bgp_asn" {
description = "The autonomous system (AS) number for Border Gateway Protocol (BGP) configuration"
type = number
}
variable "aws_vif_amazon_address" {
description = "The IPv4 CIDR address to use to send traffic to Amazon. Required for IPv4 BGP peers"
type = string
default = ""
}
variable "aws_vif_customer_address" {
description = "The IPv4 CIDR destination address to which Amazon should send traffic. Required for IPv4 BGP peers"
type = string
default = ""
}
variable "aws_vif_bgp_auth_key" {
description = "The authentication key for BGP configuration"
type = string
default = ""
}

6 changes: 5 additions & 1 deletion examples/cloud-router-2-aws-connection/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ terraform {
required_providers {
equinix = {
source = "equinix/equinix"
version = ">= 1.20.0"
version = ">= 1.25.1"
}
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}
46 changes: 44 additions & 2 deletions examples/port-2-aws-connection/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ provider "equinix" {
client_id = var.equinix_client_id
client_secret = var.equinix_client_secret
}

module "create_port_2_aws_connection" {
provider "aws" {
access_key = var.additional_info[0]["value"]
secret_key = var.additional_info[1]["value"]
region = var.zside_seller_region
}
module "port_2_aws_connection" {
source = "../../modules/port-connection"

connection_name = var.connection_name
Expand All @@ -27,3 +31,41 @@ module "create_port_2_aws_connection" {
zside_seller_region = var.zside_seller_region
zside_sp_name = var.zside_sp_name
}

data "aws_dx_connection" "connection_id" {
depends_on = [
module.port_2_aws_connection
]
name = var.connection_name
}
resource "aws_vpc" "example" {
depends_on = [
module.port_2_aws_connection
]
cidr_block = var.aws_vpc_cidr_block
}

resource "aws_vpn_gateway" "example" {
depends_on = [
module.port_2_aws_connection
]
vpc_id = aws_vpc.example.id
}

resource "aws_dx_private_virtual_interface" "example" {
depends_on = [
module.port_2_aws_connection,
aws_vpn_gateway.example,
aws_vpc.example
]

connection_id = data.aws_dx_connection.connection_id.id
name = var.aws_vif_name
vlan = var.aws_vif_vlan
address_family = var.aws_vif_address_family
bgp_asn = var.aws_vif_bgp_asn
amazon_address = var.aws_vif_amazon_address
customer_address = var.aws_vif_customer_address
bgp_auth_key = var.aws_vif_bgp_auth_key
vpn_gateway_id = aws_vpn_gateway.example.id
}
11 changes: 10 additions & 1 deletion examples/port-2-aws-connection/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
output "aws_connection_id" {
value = module.create_port_2_aws_connection.primary_connection_id
value = module.port_2_aws_connection.primary_connection_id
}
output "aws_vpc_id" {
value = aws_vpc.example.id
}
output "aws_vpn_gateway_id" {
value = aws_vpn_gateway.example.id
}
output "aws_interface_id" {
value = aws_dx_private_virtual_interface.example.id
}
9 changes: 9 additions & 0 deletions examples/port-2-aws-connection/terraform.tfvars.example
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,12 @@ additional_info = [
{ key = "accessKey", value = "<aws_access_key>" },
{ key = "secretKey", value = "<aws_secret_key>" }
]

aws_vpc_cidr_block = "10.255.255.0/28"
aws_vif_name = "port2aws"
aws_vif_vlan = "320"
aws_vif_address_family = "ipv4"
aws_vif_bgp_asn = 64999
aws_vif_amazon_address = "169.254.0.1/30"
aws_vif_customer_address = "169.254.0.2/30"
aws_vif_bgp_auth_key = "secret"
38 changes: 36 additions & 2 deletions examples/port-2-aws-connection/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ variable "equinix_client_secret" {
description = "Equinix client secret ID (consumer secret), obtained after registering app in the developer platform"
type = string
}

variable "connection_name" {
description = "Connection name. An alpha-numeric 24 characters string which can include only hyphens and underscores"
type = string
Expand All @@ -33,7 +32,6 @@ variable "purchase_order_number" {
type = string
default = ""
}

variable "aside_port_name" {
description = "Equinix A-Side Port Name"
type = string
Expand Down Expand Up @@ -77,3 +75,39 @@ variable "additional_info" {
type = list(object({ key = string, value = string }))
default = []
}
variable "aws_vpc_cidr_block" {
description = "The IPv4 CIDR block for the VPC"
type = string
}
variable "aws_vif_name" {
description = "The name for the virtual interface"
type = string
}
variable "aws_vif_vlan" {
description = " The VLAN ID"
type = string
}
variable "aws_vif_address_family" {
description = "The address family for the BGP peer. ipv4 or ipv6"
type = string
}
variable "aws_vif_bgp_asn" {
description = "The autonomous system (AS) number for Border Gateway Protocol (BGP) configuration"
type = number
}
variable "aws_vif_amazon_address" {
description = "The IPv4 CIDR address to use to send traffic to Amazon. Required for IPv4 BGP peers"
type = string
default = ""
}
variable "aws_vif_customer_address" {
description = "The IPv4 CIDR destination address to which Amazon should send traffic. Required for IPv4 BGP peers"
type = string
default = ""
}
variable "aws_vif_bgp_auth_key" {
description = "The authentication key for BGP configuration"
type = string
default = ""
}

6 changes: 5 additions & 1 deletion examples/port-2-aws-connection/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ terraform {
required_providers {
equinix = {
source = "equinix/equinix"
version = ">= 1.20.0"
version = ">= 1.25.1"
}
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}
44 changes: 43 additions & 1 deletion examples/service-token-metal-2-fabric-aws-connection/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
provider "equinix" {
client_id = var.equinix_client_id
client_secret = var.equinix_client_secret
auth_token = var.metal_auth_token // added
auth_token = var.metal_auth_token
}
provider "aws" {
access_key = var.additional_info[0]["value"]
secret_key = var.additional_info[1]["value"]
region = var.zside_seller_region
}
resource "random_string" "random" {
length = 3
Expand Down Expand Up @@ -68,3 +73,40 @@ module "metal-2-fabric-connection" {
zside_seller_region = var.zside_seller_region
zside_sp_name = var.zside_sp_name
}
data "aws_dx_connection" "connection_id" {
depends_on = [
module.metal-2-fabric-connection
]
name = var.connection_name
}

resource "aws_vpc" "example" {
depends_on = [
module.metal-2-fabric-connection
]
cidr_block = var.aws_vpc_cidr_block
}

resource "aws_vpn_gateway" "example" {
depends_on = [
module.metal-2-fabric-connection
]
vpc_id = aws_vpc.example.id
}

resource "aws_dx_private_virtual_interface" "example" {
depends_on = [
module.metal-2-fabric-connection,
aws_vpn_gateway.example,
aws_vpc.example
]
connection_id = data.aws_dx_connection.connection_id.id
name = var.aws_vif_name
vlan = var.aws_vif_vlan
address_family = var.aws_vif_address_family
bgp_asn = var.aws_vif_bgp_asn
amazon_address = var.aws_vif_amazon_address
customer_address = var.aws_vif_customer_address
bgp_auth_key = var.aws_vif_bgp_auth_key
vpn_gateway_id = aws_vpn_gateway.example.id
}
10 changes: 9 additions & 1 deletion examples/service-token-metal-2-fabric-aws-connection/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
output "metal-connection" {
value = equinix_metal_connection.metal-connection.id
}

output "fabric-connection" {
value = module.metal-2-fabric-connection.primary_connection_id
}
output "aws_vpc_id" {
value = aws_vpc.example.id
}
output "aws_vpn_gateway_id" {
value = aws_vpn_gateway.example.id
}
output "aws_interface_id" {
value = aws_dx_private_virtual_interface.example.id
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,12 @@ additional_info = [
{ key = "accessKey", value = "<aws_access_key>" },
{ key = "secretKey", value = "<aws_secret_key>" }
]

aws_vpc_cidr_block = "10.255.255.0/28"
aws_vif_name = "port2aws"
aws_vif_vlan = "320"
aws_vif_address_family = "ipv4"
aws_vif_bgp_asn = 64999
aws_vif_amazon_address = "169.254.0.1/30"
aws_vif_customer_address = "169.254.0.2/30"
aws_vif_bgp_auth_key = "secret"
Loading

0 comments on commit 8339eb2

Please sign in to comment.