AWS Amazon EC2 Transit Gateway

This page shows how to write Terraform and CloudFormation for Amazon EC2 Transit Gateway and write them securely.

aws_ec2_transit_gateway (Terraform)

The Transit Gateway in Amazon EC2 can be configured in Terraform with the resource name aws_ec2_transit_gateway. The following sections describe 3 examples of how to use the resource and its parameters.

Example Usage from GitHub

github-iconlahiruperamune/terraform-aws-import
resource "aws_ec2_transit_gateway" "NW-TransitGtwy-USWest1" {
  amazon_side_asn                 = 64512
  description                     = "HSIS-TransitGtwy"
  auto_accept_shared_attachments  = "disable"
  default_route_table_association = "disable"
  default_route_table_propagation = "disable"
github-iconanmoltoppo/Terraform
resource "aws_ec2_transit_gateway" "first" {
  provider = aws.first

  tags = {
    Name = "terraform-example"
  }
github-iconforesighttech/terraform-vpc-module
resource "aws_ec2_transit_gateway" "_" {
    auto_accept_shared_attachments = "enable"
}

resource "aws_ram_resource_association" "_" {
  resource_arn       = aws_ec2_transit_gateway._.arn

Parameters

Explanation in Terraform Registry

Manages an EC2 Transit Gateway.

AWS::EC2::TransitGateway (CloudFormation)

The TransitGateway in EC2 can be configured in CloudFormation with the resource name AWS::EC2::TransitGateway. The following sections describe how to use the resource and its parameters.

Parameters

Explanation in CloudFormation Registry

Specifies a transit gateway.

You can use a transit gateway to interconnect your virtual private clouds (VPC) and on-premises networks. After the transit gateway enters the available state, you can attach your VPCs and VPN connections to the transit gateway.

To attach your VPCs, use AWS::EC2::TransitGatewayAttachment.

To attach a VPN connection, use AWS::EC2::CustomerGateway to create a customer gateway and specify the ID of the customer gateway and the ID of the transit gateway in a call to AWS::EC2::VPNConnection.

When you create a transit gateway, we create a default transit gateway route table and use it as the default association route table and the default propagation route table. You can use AWS::EC2::TransitGatewayRouteTable to create additional transit gateway route tables. If you disable automatic route propagation, we do not create a default transit gateway route table. You can use AWS::EC2::TransitGatewayRouteTablePropagation to propagate routes from a resource attachment to a transit gateway route table. If you disable automatic associations, you can use AWS::EC2::TransitGatewayRouteTableAssociation to associate a resource attachment with a transit gateway route table.

Frequently asked questions

What is AWS Amazon EC2 Transit Gateway?

AWS Amazon EC2 Transit Gateway is a resource for Amazon EC2 of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.

Where can I find the example code for the AWS Amazon EC2 Transit Gateway?

For Terraform, the lahiruperamune/terraform-aws-import, anmoltoppo/Terraform and foresighttech/terraform-vpc-module source code examples are useful. See the Terraform Example section for further details.