Skip to content

feat: expose amazon_side_asn variable#67

Merged
Veronika Gnilitska (gberenice) merged 1 commit into
cloudposse:mainfrom
jamengual:feat/expose-amazon-side-asn
May 27, 2026
Merged

feat: expose amazon_side_asn variable#67
Veronika Gnilitska (gberenice) merged 1 commit into
cloudposse:mainfrom
jamengual:feat/expose-amazon-side-asn

Conversation

@jamengual

Copy link
Copy Markdown
Contributor

what

Adds optional amazon_side_asn variable to the module (default 64512, matching the AWS provider default) and plumbs it through to the aws_ec2_transit_gateway resource.

variable "amazon_side_asn" {
  type    = number
  default = 64512
}
 resource "aws_ec2_transit_gateway" "default" {
   ...
+  amazon_side_asn                    = var.amazon_side_asn
   auto_accept_shared_attachments     = var.auto_accept_shared_attachments
   ...
 }

why

The module currently does not expose amazon_side_asn, so all Transit Gateways created by it share the AWS default ASN 64512. This is a problem in several real-world deployments:

  • TGW-to-TGW peering (same or cross-region) — AWS rejects peering attachments when both TGWs share an ASN.
  • Direct Connect Gateway associations — each TGW associated with a DXGW must have a unique ASN.
  • BGP-based Site-to-Site VPN — when multiple TGWs terminate against the same on-premises customer gateway, identical ASNs cause unpredictable BGP best-path selection.

In our SALUS landing zone we run two Transit Gateways (prod + non-prod) in the same account; without distinct ASNs we cannot move to BGP VPNs or DX in the future without destroying and recreating both TGWs (because `amazon_side_asn` is `ForceNew` on the underlying resource).

references

test

  • `terraform init -backend=false` — OK
  • `terraform validate` — Success! The configuration is valid.
  • `terraform fmt -recursive -check` — clean
  • Default value preserves current behavior; no existing deployment will see drift.

Adds optional `amazon_side_asn` variable (default 64512, AWS default)
plumbed through to the `aws_ec2_transit_gateway` resource.

Required for use cases where multiple Transit Gateways must coexist
with distinct private ASNs:

* TGW-to-TGW peering (same or cross-region) — peering rejected when
  both sides share an ASN.
* Direct Connect Gateway associations — each TGW associated with a
  DXGW must have a unique ASN.
* BGP-based Site-to-Site VPN where multiple TGWs terminate against
  the same on-premises customer gateway.

The variable defaults to 64512 (AWS provider default) so existing
deployments are unaffected. Note that `amazon_side_asn` is
ForceNew on the underlying resource — changing it destroys and
recreates the TGW.

Refs:
* https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ec2_transit_gateway#amazon_side_asn
* https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_TransitGatewayRequestOptions.html
@jamengual

Copy link
Copy Markdown
Contributor Author

/terratest

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@gberenice Veronika Gnilitska (gberenice) merged commit 09e0f67 into cloudposse:main May 27, 2026
32 checks passed
@mergify mergify Bot removed the triage Needs triage label May 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

These changes were released in v0.13.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants