Home

Awesome

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"
  version = "~> 2.0"

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

  enable_auto_accept_shared_attachments = true

  vpc_attachments = {
    vpc = {
      vpc_id       = module.vpc.vpc_id
      subnet_ids   = module.vpc.private_subnets
      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 = {
    Purpose = "tgw-complete-example"
  }
}

module "vpc" {
  source  = "terraform-aws-modules/vpc/aws"
  version = "~> 3.0"

  name = "my-vpc"

  cidr = "10.10.0.0/16"

  azs             = ["eu-west-1a", "eu-west-1b", "eu-west-1c"]
  private_subnets = ["10.10.1.0/24", "10.10.2.0/24", "10.10.3.0/24"]

  enable_ipv6                                    = true
  private_subnet_assign_ipv6_address_on_creation = true
  private_subnet_ipv6_prefixes                   = [0, 1, 2]
}

Examples

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

Requirements

NameVersion
<a name="requirement_terraform"></a> terraform>= 0.13.1
<a name="requirement_aws"></a> aws>= 4.4

Providers

NameVersion
<a name="provider_aws"></a> aws>= 4.4

Modules

No modules.

Resources

NameType
aws_ec2_tag.thisresource
aws_ec2_transit_gateway.thisresource
aws_ec2_transit_gateway_route.thisresource
aws_ec2_transit_gateway_route_table.thisresource
aws_ec2_transit_gateway_route_table_association.thisresource
aws_ec2_transit_gateway_route_table_propagation.thisresource
aws_ec2_transit_gateway_vpc_attachment.thisresource
aws_ram_principal_association.thisresource
aws_ram_resource_association.thisresource
aws_ram_resource_share.thisresource
aws_ram_resource_share_accepter.thisresource
aws_route.thisresource

Inputs

NameDescriptionTypeDefaultRequired
<a name="input_amazon_side_asn"></a> 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
<a name="input_create_tgw"></a> create_tgwControls if TGW should be created (it affects almost all resources)booltrueno
<a name="input_create_tgw_routes"></a> create_tgw_routesControls if TGW Route Table / Routes should be createdbooltrueno
<a name="input_description"></a> descriptionDescription of the EC2 Transit Gatewaystringnullno
<a name="input_enable_auto_accept_shared_attachments"></a> enable_auto_accept_shared_attachmentsWhether resource attachment requests are automatically acceptedboolfalseno
<a name="input_enable_default_route_table_association"></a> enable_default_route_table_associationWhether resource attachments are automatically associated with the default association route tablebooltrueno
<a name="input_enable_default_route_table_propagation"></a> enable_default_route_table_propagationWhether resource attachments automatically propagate routes to the default propagation route tablebooltrueno
<a name="input_enable_dns_support"></a> enable_dns_supportShould be true to enable DNS support in the TGWbooltrueno
<a name="input_enable_multicast_support"></a> enable_multicast_supportWhether multicast support is enabledboolfalseno
<a name="input_enable_vpn_ecmp_support"></a> enable_vpn_ecmp_supportWhether VPN Equal Cost Multipath Protocol support is enabledbooltrueno
<a name="input_name"></a> nameName to be used on all the resources as identifierstring""no
<a name="input_ram_allow_external_principals"></a> ram_allow_external_principalsIndicates whether principals outside your organization can be associated with a resource share.boolfalseno
<a name="input_ram_name"></a> ram_nameThe name of the resource share of TGWstring""no
<a name="input_ram_principals"></a> 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
<a name="input_ram_resource_share_arn"></a> ram_resource_share_arnARN of RAM resource sharestring""no
<a name="input_ram_tags"></a> ram_tagsAdditional tags for the RAMmap(string){}no
<a name="input_share_tgw"></a> share_tgwWhether to share your transit gateway with other accountsbooltrueno
<a name="input_tags"></a> tagsA map of tags to add to all resourcesmap(string){}no
<a name="input_tgw_default_route_table_tags"></a> tgw_default_route_table_tagsAdditional tags for the Default TGW route tablemap(string){}no
<a name="input_tgw_route_table_tags"></a> tgw_route_table_tagsAdditional tags for the TGW route tablemap(string){}no
<a name="input_tgw_tags"></a> tgw_tagsAdditional tags for the TGWmap(string){}no
<a name="input_tgw_vpc_attachment_tags"></a> tgw_vpc_attachment_tagsAdditional tags for VPC attachmentsmap(string){}no
<a name="input_timeouts"></a> timeoutsCreate, update, and delete timeout configurations for the transit gatewaymap(string){}no
<a name="input_transit_gateway_cidr_blocks"></a> 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
<a name="input_transit_gateway_route_table_id"></a> transit_gateway_route_table_idIdentifier of EC2 Transit Gateway Route Table to use with the Target Gateway when reusing it between multiple TGWsstringnullno
<a name="input_vpc_attachments"></a> vpc_attachmentsMaps of maps of VPC details to attach to TGW. Type 'any' to disable type validation by Terraform.any{}no

Outputs

NameDescription
<a name="output_ec2_transit_gateway_arn"></a> ec2_transit_gateway_arnEC2 Transit Gateway Amazon Resource Name (ARN)
<a name="output_ec2_transit_gateway_association_default_route_table_id"></a> ec2_transit_gateway_association_default_route_table_idIdentifier of the default association route table
<a name="output_ec2_transit_gateway_id"></a> ec2_transit_gateway_idEC2 Transit Gateway identifier
<a name="output_ec2_transit_gateway_owner_id"></a> ec2_transit_gateway_owner_idIdentifier of the AWS account that owns the EC2 Transit Gateway
<a name="output_ec2_transit_gateway_propagation_default_route_table_id"></a> ec2_transit_gateway_propagation_default_route_table_idIdentifier of the default propagation route table
<a name="output_ec2_transit_gateway_route_ids"></a> ec2_transit_gateway_route_idsList of EC2 Transit Gateway Route Table identifier combined with destination
<a name="output_ec2_transit_gateway_route_table_association"></a> ec2_transit_gateway_route_table_associationMap of EC2 Transit Gateway Route Table Association attributes
<a name="output_ec2_transit_gateway_route_table_association_ids"></a> ec2_transit_gateway_route_table_association_idsList of EC2 Transit Gateway Route Table Association identifiers
<a name="output_ec2_transit_gateway_route_table_default_association_route_table"></a> ec2_transit_gateway_route_table_default_association_route_tableBoolean whether this is the default association route table for the EC2 Transit Gateway
<a name="output_ec2_transit_gateway_route_table_default_propagation_route_table"></a> ec2_transit_gateway_route_table_default_propagation_route_tableBoolean whether this is the default propagation route table for the EC2 Transit Gateway
<a name="output_ec2_transit_gateway_route_table_id"></a> ec2_transit_gateway_route_table_idEC2 Transit Gateway Route Table identifier
<a name="output_ec2_transit_gateway_route_table_propagation"></a> ec2_transit_gateway_route_table_propagationMap of EC2 Transit Gateway Route Table Propagation attributes
<a name="output_ec2_transit_gateway_route_table_propagation_ids"></a> ec2_transit_gateway_route_table_propagation_idsList of EC2 Transit Gateway Route Table Propagation identifiers
<a name="output_ec2_transit_gateway_vpc_attachment"></a> ec2_transit_gateway_vpc_attachmentMap of EC2 Transit Gateway VPC Attachment attributes
<a name="output_ec2_transit_gateway_vpc_attachment_ids"></a> ec2_transit_gateway_vpc_attachment_idsList of EC2 Transit Gateway VPC Attachment identifiers
<a name="output_ram_principal_association_id"></a> ram_principal_association_idThe Amazon Resource Name (ARN) of the Resource Share and the principal, separated by a comma
<a name="output_ram_resource_share_id"></a> ram_resource_share_idThe Amazon Resource Name (ARN) of the resource share
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

Authors

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

License

Apache 2 Licensed. See LICENSE for full details.