The copying Terraform code bit produces a Transit Entrance with VPC and VPN accessories:
company "aws" {
area="us-west-2".
}
# Produce a transit entrance.
resource "aws_ec2_transit_gateway" "example" {
description="Example transit entrance".
}
# Produce a VPC accessory.
resource "aws_ec2_transit_gateway_vpc_attachment" "example_vpc_attachment" {
subnet_ids = ["subnet-abc123", "subnet-def456"] # IDs of the subnets in the VPC to connect.
transit_gateway_id = aws_ec2_transit_gateway. example.id.
vpc_id="vpc-xyz789" # ID of the VPC to connect.
}
# Produce a VPN accessory.
resource "aws_ec2_transit_gateway_vpn_attachment" "example_vpn_attachment" {
transit_gateway_id = aws_ec2_transit_gateway. example.id.
vpn_connection_id="vpn-123456" # ID of the VPN connection to connect.
}
In this example, we’re utilizing the aws_ec2_transit_gateway resource type to produce a transit entrance in the us-west-2 area. We’re defining a description criterion to offer a description for the transit entrance.
We’re likewise utilizing the aws_ec2_transit_gateway_vpc_attachment and aws_ec2_transit_gateway_vpn_attachment resource types to produce VPC and VPN accessories, respectively. For the VPC accessory, we’re defining the IDs of the subnets in the VPC to connect with the subnet_ids criterion, and the ID of the VPC to connect with the vpc_id criterion. For the VPN accessory, we’re defining the ID of the VPN connection to connect with the vpn_connection_id criterion.
Keep In Mind that in both cases, we’re referencing the id characteristic of the transit entrance resource developed previously with the aws_ec2_transit_gateway. example.id syntax, which guarantees that the accessories are developed on the appropriate transit entrance.