terraform-aws-modules/terraform-aws-transit-gateway

Terraform module to create AWS Transit Gateway resources 🇺🇦

162

stars

86

commits

HCL

primary language

Aug 6, 2026

updated

registry.terraform.io/modules/terraform-aws-modules/transit-gateway/aws
aws
aws-vpc
terraform-module
transit-gateway

README

AWS Transit Gateway Terraform module

Terraform module which creates Transit Gateway resources on AWS.

Usage with VPC module

module "tgw" {
  source  = "terraform-aws-modules/transit-gateway/aws"

  name        = "my-tgw"
  description = "My TGW shared with several other AWS accounts"

  enable_auto_accept_shared_attachments = true

  vpc_attachments = {
    vpc = {
      vpc_id       = "vpc-1234556abcdef"
      subnet_ids   = ["subnet-abcde012", "subnet-bcde012a", "subnet-fghi345a"]
      dns_support  = true
      ipv6_support = true

      tgw_routes = [
        {
          destination_cidr_block = "30.0.0.0/16"
        },
        {
          blackhole              = true
          destination_cidr_block = "40.0.0.0/20"
        }
      ]
    }
  }

  ram_allow_external_principals = true
  ram_principals                = [307990089504]

  tags = {
    Terraform   = "true"
    Environment = "dev"
  }
}

Examples

Requirements

NameVersion
terraform>= 1.5.7
aws>= 6.28

Providers

NameVersion
aws>= 6.28

Modules

No modules.

Resources

Inputs

NameDescriptionTypeDefaultRequired
amazon_side_asnThe Autonomous System Number (ASN) for the Amazon side of the gateway. By default the TGW is created with the current default Amazon ASN.stringnullno
create_tgwControls if TGW should be created (it affects almost all resources)booltrueno
create_tgw_routesControls if TGW Route Table / Routes should be createdbooltrueno
descriptionDescription of the EC2 Transit Gatewaystringnullno
enable_auto_accept_shared_attachmentsWhether resource attachment requests are automatically acceptedboolfalseno
enable_default_route_table_associationWhether resource attachments are automatically associated with the default association route tablebooltrueno
enable_default_route_table_propagationWhether resource attachments automatically propagate routes to the default propagation route tablebooltrueno
enable_dns_supportShould be true to enable DNS support in the TGWbooltrueno
enable_encryption_supportShould be true to enable encryption support in the TGWboolfalseno
enable_multicast_supportWhether multicast support is enabledboolfalseno
enable_sg_referencing_supportIndicates whether to enable security group referencing supportbooltrueno
enable_vpn_ecmp_supportWhether VPN Equal Cost Multipath Protocol support is enabledbooltrueno
nameName to be used on all the resources as identifierstring""no
ram_allow_external_principalsIndicates whether principals outside your organization can be associated with a resource share.boolfalseno
ram_nameThe name of the resource share of TGWstring""no
ram_principalsA list of principals to share TGW with. Possible values are an AWS account ID, an AWS Organizations Organization ARN, or an AWS Organizations Organization Unit ARNlist(string)[]no
ram_resource_share_arnARN of RAM resource sharestring""no
ram_tagsAdditional tags for the RAMmap(string){}no
regionRegion where the resource(s) will be managed. Defaults to the region set in the provider configurationstringnullno
share_tgwWhether to share your transit gateway with other accountsbooltrueno
tagsA map of tags to add to all resourcesmap(string){}no
tgw_default_route_table_tagsAdditional tags for the Default TGW route tablemap(string){}no
tgw_route_table_tagsAdditional tags for the TGW route tablemap(string){}no
tgw_tagsAdditional tags for the TGWmap(string){}no
tgw_vpc_attachment_tagsAdditional tags for VPC attachmentsmap(string){}no
timeoutsCreate, update, and delete timeout configurations for the transit gateway
object({
create = optional(string)
update = optional(string)
delete = optional(string)
})
nullno
transit_gateway_cidr_blocksOne or more IPv4 or IPv6 CIDR blocks for the transit gateway. Must be a size /24 CIDR block or larger for IPv4, or a size /64 CIDR block or larger for IPv6list(string)[]no
transit_gateway_route_table_idIdentifier of EC2 Transit Gateway Route Table to use with the Target Gateway when reusing it between multiple TGWsstringnullno
vpc_attachmentsMaps of maps of VPC details to attach to TGW. Type 'any' to disable type validation by Terraform.any{}no

Outputs

NameDescription
ec2_transit_gateway_arnEC2 Transit Gateway Amazon Resource Name (ARN)
ec2_transit_gateway_association_default_route_table_idIdentifier of the default association route table
ec2_transit_gateway_idEC2 Transit Gateway identifier
ec2_transit_gateway_owner_idIdentifier of the AWS account that owns the EC2 Transit Gateway
ec2_transit_gateway_propagation_default_route_table_idIdentifier of the default propagation route table
ec2_transit_gateway_route_idsList of EC2 Transit Gateway Route Table identifier combined with destination
ec2_transit_gateway_route_table_associationMap of EC2 Transit Gateway Route Table Association attributes
ec2_transit_gateway_route_table_association_idsList of EC2 Transit Gateway Route Table Association identifiers
ec2_transit_gateway_route_table_default_association_route_tableBoolean whether this is the default association route table for the EC2 Transit Gateway
ec2_transit_gateway_route_table_default_propagation_route_tableBoolean whether this is the default propagation route table for the EC2 Transit Gateway
ec2_transit_gateway_route_table_idEC2 Transit Gateway Route Table identifier
ec2_transit_gateway_route_table_propagationMap of EC2 Transit Gateway Route Table Propagation attributes
ec2_transit_gateway_route_table_propagation_idsList of EC2 Transit Gateway Route Table Propagation identifiers
ec2_transit_gateway_vpc_attachmentMap of EC2 Transit Gateway VPC Attachment attributes
ec2_transit_gateway_vpc_attachment_idsList of EC2 Transit Gateway VPC Attachment identifiers
ram_principal_association_idThe Amazon Resource Name (ARN) of the Resource Share and the principal, separated by a comma
ram_resource_share_idThe Amazon Resource Name (ARN) of the resource share

Authors

Module is maintained by Anton Babenko with help from these awesome contributors.

License

Apache 2 Licensed. See LICENSE for full details.

Contributors

antonbabenko

17 commits

bryantbiggs

16 commits

betajobot

12 commits

terraform-aws-modules/terraform-aws-transit-gateway

Terraform module to create AWS Transit Gateway resources 🇺🇦

162

stars

86

commits

HCL

primary language

Aug 6, 2026

updated

registry.terraform.io/modules/terraform-aws-modules/transit-gateway/aws
aws
aws-vpc
terraform-module
transit-gateway

README

AWS Transit Gateway Terraform module

Terraform module which creates Transit Gateway resources on AWS.

Usage with VPC module

module "tgw" {
  source  = "terraform-aws-modules/transit-gateway/aws"

  name        = "my-tgw"
  description = "My TGW shared with several other AWS accounts"

  enable_auto_accept_shared_attachments = true

  vpc_attachments = {
    vpc = {
      vpc_id       = "vpc-1234556abcdef"
      subnet_ids   = ["subnet-abcde012", "subnet-bcde012a", "subnet-fghi345a"]
      dns_support  = true
      ipv6_support = true

      tgw_routes = [
        {
          destination_cidr_block = "30.0.0.0/16"
        },
        {
          blackhole              = true
          destination_cidr_block = "40.0.0.0/20"
        }
      ]
    }
  }

  ram_allow_external_principals = true
  ram_principals                = [307990089504]

  tags = {
    Terraform   = "true"
    Environment = "dev"
  }
}

Examples

Requirements

NameVersion
terraform>= 1.5.7
aws>= 6.28

Providers

NameVersion
aws>= 6.28

Modules

No modules.

Resources

Inputs

NameDescriptionTypeDefaultRequired
amazon_side_asnThe Autonomous System Number (ASN) for the Amazon side of the gateway. By default the TGW is created with the current default Amazon ASN.stringnullno
create_tgwControls if TGW should be created (it affects almost all resources)booltrueno
create_tgw_routesControls if TGW Route Table / Routes should be createdbooltrueno
descriptionDescription of the EC2 Transit Gatewaystringnullno
enable_auto_accept_shared_attachmentsWhether resource attachment requests are automatically acceptedboolfalseno
enable_default_route_table_associationWhether resource attachments are automatically associated with the default association route tablebooltrueno
enable_default_route_table_propagationWhether resource attachments automatically propagate routes to the default propagation route tablebooltrueno
enable_dns_supportShould be true to enable DNS support in the TGWbooltrueno
enable_encryption_supportShould be true to enable encryption support in the TGWboolfalseno
enable_multicast_supportWhether multicast support is enabledboolfalseno
enable_sg_referencing_supportIndicates whether to enable security group referencing supportbooltrueno
enable_vpn_ecmp_supportWhether VPN Equal Cost Multipath Protocol support is enabledbooltrueno
nameName to be used on all the resources as identifierstring""no
ram_allow_external_principalsIndicates whether principals outside your organization can be associated with a resource share.boolfalseno
ram_nameThe name of the resource share of TGWstring""no
ram_principalsA list of principals to share TGW with. Possible values are an AWS account ID, an AWS Organizations Organization ARN, or an AWS Organizations Organization Unit ARNlist(string)[]no
ram_resource_share_arnARN of RAM resource sharestring""no
ram_tagsAdditional tags for the RAMmap(string){}no
regionRegion where the resource(s) will be managed. Defaults to the region set in the provider configurationstringnullno
share_tgwWhether to share your transit gateway with other accountsbooltrueno
tagsA map of tags to add to all resourcesmap(string){}no
tgw_default_route_table_tagsAdditional tags for the Default TGW route tablemap(string){}no
tgw_route_table_tagsAdditional tags for the TGW route tablemap(string){}no
tgw_tagsAdditional tags for the TGWmap(string){}no
tgw_vpc_attachment_tagsAdditional tags for VPC attachmentsmap(string){}no
timeoutsCreate, update, and delete timeout configurations for the transit gateway
object({
create = optional(string)
update = optional(string)
delete = optional(string)
})
nullno
transit_gateway_cidr_blocksOne or more IPv4 or IPv6 CIDR blocks for the transit gateway. Must be a size /24 CIDR block or larger for IPv4, or a size /64 CIDR block or larger for IPv6list(string)[]no
transit_gateway_route_table_idIdentifier of EC2 Transit Gateway Route Table to use with the Target Gateway when reusing it between multiple TGWsstringnullno
vpc_attachmentsMaps of maps of VPC details to attach to TGW. Type 'any' to disable type validation by Terraform.any{}no

Outputs

NameDescription
ec2_transit_gateway_arnEC2 Transit Gateway Amazon Resource Name (ARN)
ec2_transit_gateway_association_default_route_table_idIdentifier of the default association route table
ec2_transit_gateway_idEC2 Transit Gateway identifier
ec2_transit_gateway_owner_idIdentifier of the AWS account that owns the EC2 Transit Gateway
ec2_transit_gateway_propagation_default_route_table_idIdentifier of the default propagation route table
ec2_transit_gateway_route_idsList of EC2 Transit Gateway Route Table identifier combined with destination
ec2_transit_gateway_route_table_associationMap of EC2 Transit Gateway Route Table Association attributes
ec2_transit_gateway_route_table_association_idsList of EC2 Transit Gateway Route Table Association identifiers
ec2_transit_gateway_route_table_default_association_route_tableBoolean whether this is the default association route table for the EC2 Transit Gateway
ec2_transit_gateway_route_table_default_propagation_route_tableBoolean whether this is the default propagation route table for the EC2 Transit Gateway
ec2_transit_gateway_route_table_idEC2 Transit Gateway Route Table identifier
ec2_transit_gateway_route_table_propagationMap of EC2 Transit Gateway Route Table Propagation attributes
ec2_transit_gateway_route_table_propagation_idsList of EC2 Transit Gateway Route Table Propagation identifiers
ec2_transit_gateway_vpc_attachmentMap of EC2 Transit Gateway VPC Attachment attributes
ec2_transit_gateway_vpc_attachment_idsList of EC2 Transit Gateway VPC Attachment identifiers
ram_principal_association_idThe Amazon Resource Name (ARN) of the Resource Share and the principal, separated by a comma
ram_resource_share_idThe Amazon Resource Name (ARN) of the resource share

Authors

Module is maintained by Anton Babenko with help from these awesome contributors.

License

Apache 2 Licensed. See LICENSE for full details.

Contributors

antonbabenko

17 commits

bryantbiggs

16 commits

betajobot

12 commits

Languages

HCL

100.0%