Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support AWS Direct Connect Gateway with option to create #17

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand All @@ -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

Expand Down
27 changes: 27 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <<EOF
Expand All @@ -143,6 +149,15 @@ variable "aws_dx_vgw_id" {
default = ""
nickzxcv marked this conversation as resolved.
Show resolved Hide resolved
}

variable "aws_dx_gateway_id" {
type = string
description = <<EOF
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.
nickzxcv marked this conversation as resolved.
Show resolved Hide resolved
EOF
default = ""
nickzxcv marked this conversation as resolved.
Show resolved Hide resolved
}

variable "aws_vpc_id" {
type = string
description = <<EOF
Expand All @@ -158,6 +173,18 @@ variable "aws_vpn_gateway_name" {
default = ""
}

variable "aws_dx_gateway_name" {
type = string
description = "The name for the DX Gateway. It will be auto-generated if not specified."
default = ""
}

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
nickzxcv marked this conversation as resolved.
Show resolved Hide resolved
}

variable "aws_dx_vif_address_family" {
type = string
description = "The address family for the BGP peer. ipv4 or ipv6"
Expand Down
Loading