Skip to content

Commit

Permalink
CXF-89291: Replacing aws_vpn_gateway with aws_dx_gateway for their vi…
Browse files Browse the repository at this point in the history
…rtual interface connections (#39)

* fix:Replacing aws_vpn_gateway with aws_dx_gateway resource

* chore: Removing extra space

* chore: fixing indentation

* chore: Adding trailing line
  • Loading branch information
srushti-patl authored Mar 7, 2024
1 parent 287758f commit 6bb6e04
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 59 deletions.
25 changes: 9 additions & 16 deletions examples/cloud-router-2-aws-connection/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,41 +31,34 @@ module "cloud_router_aws_connection" {
zside_fabric_sp_name = var.zside_fabric_sp_name
}

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

resource "aws_vpc" "example" {
resource "aws_dx_gateway" "aws_gateway" {
depends_on = [
module.cloud_router_aws_connection
]
cidr_block = var.aws_vpc_cidr_block
name = var.aws_gateway_name
amazon_side_asn = var.aws_gateway_asn
}

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" {
resource "aws_dx_private_virtual_interface" "aws_virtual_interface" {
depends_on = [
module.cloud_router_aws_connection,
aws_vpn_gateway.example,
aws_vpc.example
aws_dx_gateway.aws_gateway
]
connection_id = data.aws_dx_connection.connection_id.id
connection_id = data.aws_dx_connection.aws_connection.id
name = var.aws_vif_name
vlan = var.aws_vif_vlan
vlan = data.aws_dx_connection.aws_connection.vlan_id
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
dx_gateway_id = aws_dx_gateway.aws_gateway.id
}

11 changes: 4 additions & 7 deletions examples/cloud-router-2-aws-connection/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
output "module_output" {
output "aws_connection_id" {
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_dx_gateway_id" {
value = aws_dx_gateway.aws_gateway.id
}
output "aws_interface_id" {
value = aws_dx_private_virtual_interface.example.id
value = aws_dx_private_virtual_interface.aws_virtual_interface.id
}

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ additional_info = [
{ key = "secretKey", value = "<aws_secret_key>" }
]

aws_vpc_cidr_block = "10.255.255.0/28"
aws_gateway_name = "aws_gateway"
aws_gateway_asn = 64518
aws_vif_name = "port2aws"
aws_vif_vlan = "320"
aws_vif_address_family = "ipv4"
Expand Down
13 changes: 8 additions & 5 deletions examples/cloud-router-2-aws-connection/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ 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
Expand Down Expand Up @@ -111,4 +107,11 @@ variable "aws_vif_bgp_auth_key" {
type = string
default = ""
}

variable "aws_gateway_name" {
description = "The name of the Gateway"
type = string
}
variable "aws_gateway_asn" {
description = "The ASN to be configured on the Amazon side of the connection. The ASN must be in the private range of 64,512 to 65,534 or 4,200,000,000 to 4,294,967,294"
type = number
}
26 changes: 9 additions & 17 deletions examples/port-2-aws-connection/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ module "port_2_aws_connection" {
# A-side
aside_port_name = var.aside_port_name
aside_vlan_tag = var.aside_vlan_tag
aside_vlan_inner_tag = var.aside_vlan_inner_tag

# Z-side
zside_ap_type = var.zside_ap_type
Expand All @@ -32,40 +31,33 @@ module "port_2_aws_connection" {
zside_sp_name = var.zside_sp_name
}

data "aws_dx_connection" "connection_id" {
data "aws_dx_connection" "aws_connection" {
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" {
resource "aws_dx_gateway" "aws_gateway" {
depends_on = [
module.port_2_aws_connection
]
vpc_id = aws_vpc.example.id
name = var.aws_gateway_name
amazon_side_asn = var.aws_gateway_asn
}

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

connection_id = data.aws_dx_connection.connection_id.id
connection_id = data.aws_dx_connection.aws_connection.id
name = var.aws_vif_name
vlan = var.aws_vif_vlan
vlan = data.aws_dx_connection.aws_connection.vlan_id
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
dx_gateway_id = aws_dx_gateway.aws_gateway.id
}
9 changes: 3 additions & 6 deletions examples/port-2-aws-connection/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
output "aws_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_dx_gateway_id" {
value = aws_dx_gateway.aws_gateway.id
}
output "aws_interface_id" {
value = aws_dx_private_virtual_interface.example.id
value = aws_dx_private_virtual_interface.aws_virtual_interface.id
}
3 changes: 2 additions & 1 deletion examples/port-2-aws-connection/terraform.tfvars.example
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ additional_info = [
{ key = "secretKey", value = "<aws_secret_key>" }
]

aws_vpc_cidr_block = "10.255.255.0/28"
aws_gateway_name = "aws_gateway"
aws_gateway_asn = 64518
aws_vif_name = "port2aws"
aws_vif_vlan = "320"
aws_vif_address_family = "ipv4"
Expand Down
14 changes: 8 additions & 6 deletions examples/port-2-aws-connection/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ variable "aside_port_name" {
description = "Equinix A-Side Port Name"
type = string
}

variable "aside_vlan_tag" {
description = "Vlan Tag information, outer vlanSTag for QINQ connections"
type = string
Expand Down Expand Up @@ -75,10 +74,6 @@ 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
Expand Down Expand Up @@ -110,4 +105,11 @@ variable "aws_vif_bgp_auth_key" {
type = string
default = ""
}

variable "aws_gateway_name" {
description = "The name of the Gateway"
type = string
}
variable "aws_gateway_asn" {
description = "The ASN to be configured on the Amazon side of the connection. The ASN must be in the private range of 64,512 to 65,534 or 4,200,000,000 to 4,294,967,294"
type = number
}

0 comments on commit 6bb6e04

Please sign in to comment.