Resource: aws_ec2_transit_gateway_vpc_attachment

Manages an EC2 Transit Gateway VPC Attachment. For examples of custom route table association and propagation, see the EC2 Transit Gateway Networking Examples Guide.

Example Usage

resource "aws_ec2_transit_gateway_vpc_attachment" "example" {
  subnet_ids         = [aws_subnet.example.id]
  transit_gateway_id = aws_ec2_transit_gateway.example.id
  vpc_id             = aws_vpc.example.id
}

A full example of how to create a Transit Gateway in one AWS account, share it with a second AWS account, and attach a VPC in the second account to the Transit Gateway via the aws_ec2_transit_gateway_vpc_attachment and aws_ec2_transit_gateway_vpc_attachment_accepter resources can be found in the ./examples/transit-gateway-cross-account-vpc-attachment directory within the Github Repository.

Argument Reference

This resource supports the following arguments:

Attribute Reference

This resource exports the following attributes in addition to the arguments above:

Import

In Terraform v1.5.0 and later, use an import block to import aws_ec2_transit_gateway_vpc_attachment using the EC2 Transit Gateway Attachment identifier. For example:

import {
  to = aws_ec2_transit_gateway_vpc_attachment.example
  id = "tgw-attach-12345678"
}

Using terraform import, import aws_ec2_transit_gateway_vpc_attachment using the EC2 Transit Gateway Attachment identifier. For example:

% terraform import aws_ec2_transit_gateway_vpc_attachment.example tgw-attach-12345678