Skip to content
GitHubXDiscordRSS

TransitGatewayAttachment

Learn how to create, update, and manage AWS EC2 TransitGatewayAttachments using Alchemy Cloud Control.

The TransitGatewayAttachment resource lets you manage AWS EC2 Transit Gateway Attachments for connecting VPCs and on-premises networks to a transit gateway.

Create a basic Transit Gateway Attachment with required properties and one optional tag.

import AWS from "alchemy/aws/control";
const transitGatewayAttachment = await AWS.EC2.TransitGatewayAttachment("myTransitGatewayAttachment", {
TransitGatewayId: "tgw-0abcd1234efgh5678",
VpcId: "vpc-0abcd1234efgh5678",
SubnetIds: ["subnet-0abcd1234efgh5678", "subnet-1abcd1234efgh5678"],
Tags: [
{
Key: "Name",
Value: "MyTransitGatewayAttachment"
}
]
});

Configure a Transit Gateway Attachment with specific options for routing.

const advancedTransitGatewayAttachment = await AWS.EC2.TransitGatewayAttachment("advancedTransitGatewayAttachment", {
TransitGatewayId: "tgw-0abcd1234efgh5678",
VpcId: "vpc-0abcd1234efgh5678",
SubnetIds: ["subnet-0abcd1234efgh5678", "subnet-1abcd1234efgh5678"],
Options: {
ApplianceMode: "enable",
DnsSupport: "enable",
IPv6Support: "disable"
},
Tags: [
{
Key: "Environment",
Value: "Production"
}
]
});

Adopt an existing Transit Gateway Attachment instead of failing if it already exists.

const adoptTransitGatewayAttachment = await AWS.EC2.TransitGatewayAttachment("adoptExistingTransitGatewayAttachment", {
TransitGatewayId: "tgw-0abcd1234efgh5678",
VpcId: "vpc-0abcd1234efgh5678",
SubnetIds: ["subnet-0abcd1234efgh5678"],
adopt: true
});