From 0bf63fadcf627f650a3e55fc303e0c71f50f59e6 Mon Sep 17 00:00:00 2001 From: Nick Schmalenberger Date: Mon, 6 Nov 2023 22:21:56 +0000 Subject: [PATCH 1/5] Support AWS Direct Connect Gateway with option to create --- main.tf | 9 +++++++++ variables.tf | 27 +++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/main.tf b/main.tf index ec49a36..32cccdb 100644 --- a/main.tf +++ b/main.tf @@ -4,6 +4,7 @@ locals { if action_data["key"] == "awsConnectionId" ]) aws_vgw_id = var.aws_dx_create_vgw ? aws_vpn_gateway.this[0].id : var.aws_dx_vgw_id + aws_dx_gateway_id = var.aws_dx_create_dx_gw ? aws_dx_gateway.this[0].id : var.aws_dx_gateway_id aws_vpc_id = var.aws_dx_create_vgw ? data.aws_vpc.this[0].id : "" aws_region = data.aws_region.this.name } @@ -67,6 +68,7 @@ resource "aws_dx_private_virtual_interface" "this" { bgp_auth_key = var.aws_dx_bgp_auth_key vpn_gateway_id = local.aws_vgw_id + dx_gateway_id = local.aws_dx_gateway_id tags = var.aws_tags } @@ -83,6 +85,13 @@ resource "aws_vpn_gateway" "this" { ) } +resource "aws_dx_gateway" "this" { + count = var.aws_dx_create_dx_gw ? 1 : 0 + + name = var.aws_dx_gateway_name != "" ? var.aws_dx_gateway_name : lower(format("dxgw-%s", random_string.this.result)) + amazon_side_asn = var.aws_dx_gateway_asn +} + resource "equinix_network_bgp" "this" { count = alltrue([var.aws_dx_create_vif, var.network_edge_device_id != "", var.network_edge_configure_bgp]) ? 1 : 0 diff --git a/variables.tf b/variables.tf index 7a3723b..a4d0451 100644 --- a/variables.tf +++ b/variables.tf @@ -134,6 +134,12 @@ variable "aws_dx_create_vgw" { default = false } +variable "aws_dx_create_dx_gw" { + type = bool + description = "Create a DX Gateway." + default = false +} + variable "aws_dx_vgw_id" { type = string description = < Date: Wed, 15 Nov 2023 19:22:23 -0500 Subject: [PATCH 2/5] Update variables.tf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Óscar Cobles <68897552+ocobles@users.noreply.github.com> --- variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variables.tf b/variables.tf index a4d0451..99fafb1 100644 --- a/variables.tf +++ b/variables.tf @@ -153,7 +153,7 @@ variable "aws_dx_gateway_id" { type = string description = < Date: Wed, 15 Nov 2023 19:22:34 -0500 Subject: [PATCH 3/5] Update variables.tf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Óscar Cobles <68897552+ocobles@users.noreply.github.com> --- variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variables.tf b/variables.tf index 99fafb1..ed322f7 100644 --- a/variables.tf +++ b/variables.tf @@ -155,7 +155,7 @@ variable "aws_dx_gateway_id" { If 'aws_dx_create_vif' is true but you already have an existing DX Gateway you can left 'aws_dx_create_dx_gw' false and set your DX Gateway id instead. 'aws_dx_gateway_id' conflicts with 'aws_dx_vgw_id'. EOF - default = "" + default = null } variable "aws_vpc_id" { From 68d724deaec8f3b2bb8996cda1f1cf102f112044 Mon Sep 17 00:00:00 2001 From: Nick Schmalenberger Date: Wed, 15 Nov 2023 19:22:52 -0500 Subject: [PATCH 4/5] Update variables.tf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Óscar Cobles <68897552+ocobles@users.noreply.github.com> --- variables.tf | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/variables.tf b/variables.tf index ed322f7..cb1d998 100644 --- a/variables.tf +++ b/variables.tf @@ -181,8 +181,11 @@ variable "aws_dx_gateway_name" { variable "aws_dx_gateway_asn" { type = number - description = "The ASN for the Amazon side of the connection. It will be auto-generated if not specified." - default = null + description = < Date: Thu, 16 Nov 2023 00:27:57 +0000 Subject: [PATCH 5/5] change aws_dx_vgw_id default from "" to null --- variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variables.tf b/variables.tf index cb1d998..c49c59a 100644 --- a/variables.tf +++ b/variables.tf @@ -146,7 +146,7 @@ variable "aws_dx_vgw_id" { If 'aws_dx_create_vif' is true but you already have an existing VGW you can left 'aws_dx_create_vgw' false and set your VGW id instead. EOF - default = "" + default = null } variable "aws_dx_gateway_id" {