1. Packages
  2. AWS
  3. API Docs
  4. ec2transitgateway
  5. RouteTableAssociation
AWS v7.10.0 published on Friday, Oct 24, 2025 by Pulumi

aws.ec2transitgateway.RouteTableAssociation

Get Started
aws logo
AWS v7.10.0 published on Friday, Oct 24, 2025 by Pulumi

    Manages an EC2 Transit Gateway Route Table association.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const example = new aws.ec2transitgateway.RouteTableAssociation("example", {
        transitGatewayAttachmentId: exampleAwsEc2TransitGatewayVpcAttachment.id,
        transitGatewayRouteTableId: exampleAwsEc2TransitGatewayRouteTable.id,
    });
    
    import pulumi
    import pulumi_aws as aws
    
    example = aws.ec2transitgateway.RouteTableAssociation("example",
        transit_gateway_attachment_id=example_aws_ec2_transit_gateway_vpc_attachment["id"],
        transit_gateway_route_table_id=example_aws_ec2_transit_gateway_route_table["id"])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/ec2transitgateway"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := ec2transitgateway.NewRouteTableAssociation(ctx, "example", &ec2transitgateway.RouteTableAssociationArgs{
    			TransitGatewayAttachmentId: pulumi.Any(exampleAwsEc2TransitGatewayVpcAttachment.Id),
    			TransitGatewayRouteTableId: pulumi.Any(exampleAwsEc2TransitGatewayRouteTable.Id),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var example = new Aws.Ec2TransitGateway.RouteTableAssociation("example", new()
        {
            TransitGatewayAttachmentId = exampleAwsEc2TransitGatewayVpcAttachment.Id,
            TransitGatewayRouteTableId = exampleAwsEc2TransitGatewayRouteTable.Id,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.ec2transitgateway.RouteTableAssociation;
    import com.pulumi.aws.ec2transitgateway.RouteTableAssociationArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var example = new RouteTableAssociation("example", RouteTableAssociationArgs.builder()
                .transitGatewayAttachmentId(exampleAwsEc2TransitGatewayVpcAttachment.id())
                .transitGatewayRouteTableId(exampleAwsEc2TransitGatewayRouteTable.id())
                .build());
    
        }
    }
    
    resources:
      example:
        type: aws:ec2transitgateway:RouteTableAssociation
        properties:
          transitGatewayAttachmentId: ${exampleAwsEc2TransitGatewayVpcAttachment.id}
          transitGatewayRouteTableId: ${exampleAwsEc2TransitGatewayRouteTable.id}
    

    Direct Connect Gateway Association

    When associating a Direct Connect Gateway attachment, reference the transit_gateway_attachment_id attribute directly from the aws.directconnect.GatewayAssociation resource (available in v6.5.0+):

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const example = new aws.directconnect.Gateway("example", {
        name: "example",
        amazonSideAsn: "64512",
    });
    const exampleTransitGateway = new aws.ec2transitgateway.TransitGateway("example", {description: "example"});
    const exampleGatewayAssociation = new aws.directconnect.GatewayAssociation("example", {
        dxGatewayId: example.id,
        associatedGatewayId: exampleTransitGateway.id,
        allowedPrefixes: ["10.0.0.0/16"],
    });
    const exampleRouteTable = new aws.ec2transitgateway.RouteTable("example", {transitGatewayId: exampleTransitGateway.id});
    // Correct: Reference the attachment ID directly from the association resource
    const exampleRouteTableAssociation = new aws.ec2transitgateway.RouteTableAssociation("example", {
        transitGatewayAttachmentId: exampleGatewayAssociation.transitGatewayAttachmentId,
        transitGatewayRouteTableId: exampleRouteTable.id,
    });
    
    import pulumi
    import pulumi_aws as aws
    
    example = aws.directconnect.Gateway("example",
        name="example",
        amazon_side_asn="64512")
    example_transit_gateway = aws.ec2transitgateway.TransitGateway("example", description="example")
    example_gateway_association = aws.directconnect.GatewayAssociation("example",
        dx_gateway_id=example.id,
        associated_gateway_id=example_transit_gateway.id,
        allowed_prefixes=["10.0.0.0/16"])
    example_route_table = aws.ec2transitgateway.RouteTable("example", transit_gateway_id=example_transit_gateway.id)
    # Correct: Reference the attachment ID directly from the association resource
    example_route_table_association = aws.ec2transitgateway.RouteTableAssociation("example",
        transit_gateway_attachment_id=example_gateway_association.transit_gateway_attachment_id,
        transit_gateway_route_table_id=example_route_table.id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/directconnect"
    	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/ec2transitgateway"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		example, err := directconnect.NewGateway(ctx, "example", &directconnect.GatewayArgs{
    			Name:          pulumi.String("example"),
    			AmazonSideAsn: pulumi.String("64512"),
    		})
    		if err != nil {
    			return err
    		}
    		exampleTransitGateway, err := ec2transitgateway.NewTransitGateway(ctx, "example", &ec2transitgateway.TransitGatewayArgs{
    			Description: pulumi.String("example"),
    		})
    		if err != nil {
    			return err
    		}
    		exampleGatewayAssociation, err := directconnect.NewGatewayAssociation(ctx, "example", &directconnect.GatewayAssociationArgs{
    			DxGatewayId:         example.ID(),
    			AssociatedGatewayId: exampleTransitGateway.ID(),
    			AllowedPrefixes: pulumi.StringArray{
    				pulumi.String("10.0.0.0/16"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		exampleRouteTable, err := ec2transitgateway.NewRouteTable(ctx, "example", &ec2transitgateway.RouteTableArgs{
    			TransitGatewayId: exampleTransitGateway.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		// Correct: Reference the attachment ID directly from the association resource
    		_, err = ec2transitgateway.NewRouteTableAssociation(ctx, "example", &ec2transitgateway.RouteTableAssociationArgs{
    			TransitGatewayAttachmentId: exampleGatewayAssociation.TransitGatewayAttachmentId,
    			TransitGatewayRouteTableId: exampleRouteTable.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var example = new Aws.DirectConnect.Gateway("example", new()
        {
            Name = "example",
            AmazonSideAsn = "64512",
        });
    
        var exampleTransitGateway = new Aws.Ec2TransitGateway.TransitGateway("example", new()
        {
            Description = "example",
        });
    
        var exampleGatewayAssociation = new Aws.DirectConnect.GatewayAssociation("example", new()
        {
            DxGatewayId = example.Id,
            AssociatedGatewayId = exampleTransitGateway.Id,
            AllowedPrefixes = new[]
            {
                "10.0.0.0/16",
            },
        });
    
        var exampleRouteTable = new Aws.Ec2TransitGateway.RouteTable("example", new()
        {
            TransitGatewayId = exampleTransitGateway.Id,
        });
    
        // Correct: Reference the attachment ID directly from the association resource
        var exampleRouteTableAssociation = new Aws.Ec2TransitGateway.RouteTableAssociation("example", new()
        {
            TransitGatewayAttachmentId = exampleGatewayAssociation.TransitGatewayAttachmentId,
            TransitGatewayRouteTableId = exampleRouteTable.Id,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.directconnect.Gateway;
    import com.pulumi.aws.directconnect.GatewayArgs;
    import com.pulumi.aws.ec2transitgateway.TransitGateway;
    import com.pulumi.aws.ec2transitgateway.TransitGatewayArgs;
    import com.pulumi.aws.directconnect.GatewayAssociation;
    import com.pulumi.aws.directconnect.GatewayAssociationArgs;
    import com.pulumi.aws.ec2transitgateway.RouteTable;
    import com.pulumi.aws.ec2transitgateway.RouteTableArgs;
    import com.pulumi.aws.ec2transitgateway.RouteTableAssociation;
    import com.pulumi.aws.ec2transitgateway.RouteTableAssociationArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var example = new Gateway("example", GatewayArgs.builder()
                .name("example")
                .amazonSideAsn("64512")
                .build());
    
            var exampleTransitGateway = new TransitGateway("exampleTransitGateway", TransitGatewayArgs.builder()
                .description("example")
                .build());
    
            var exampleGatewayAssociation = new GatewayAssociation("exampleGatewayAssociation", GatewayAssociationArgs.builder()
                .dxGatewayId(example.id())
                .associatedGatewayId(exampleTransitGateway.id())
                .allowedPrefixes("10.0.0.0/16")
                .build());
    
            var exampleRouteTable = new RouteTable("exampleRouteTable", RouteTableArgs.builder()
                .transitGatewayId(exampleTransitGateway.id())
                .build());
    
            // Correct: Reference the attachment ID directly from the association resource
            var exampleRouteTableAssociation = new RouteTableAssociation("exampleRouteTableAssociation", RouteTableAssociationArgs.builder()
                .transitGatewayAttachmentId(exampleGatewayAssociation.transitGatewayAttachmentId())
                .transitGatewayRouteTableId(exampleRouteTable.id())
                .build());
    
        }
    }
    
    resources:
      example:
        type: aws:directconnect:Gateway
        properties:
          name: example
          amazonSideAsn: 64512
      exampleTransitGateway:
        type: aws:ec2transitgateway:TransitGateway
        name: example
        properties:
          description: example
      exampleGatewayAssociation:
        type: aws:directconnect:GatewayAssociation
        name: example
        properties:
          dxGatewayId: ${example.id}
          associatedGatewayId: ${exampleTransitGateway.id}
          allowedPrefixes:
            - 10.0.0.0/16
      exampleRouteTable:
        type: aws:ec2transitgateway:RouteTable
        name: example
        properties:
          transitGatewayId: ${exampleTransitGateway.id}
      # Correct: Reference the attachment ID directly from the association resource
      exampleRouteTableAssociation:
        type: aws:ec2transitgateway:RouteTableAssociation
        name: example
        properties:
          transitGatewayAttachmentId: ${exampleGatewayAssociation.transitGatewayAttachmentId}
          transitGatewayRouteTableId: ${exampleRouteTable.id}
    

    NOTE: Avoid using the aws.ec2transitgateway.getDirectConnectGatewayAttachment data source to retrieve the attachment ID, as this can cause unnecessary resource recreation when unrelated attributes of the Direct Connect Gateway association change (such as allowed_prefixes). Always reference the transit_gateway_attachment_id attribute directly from the aws.directconnect.GatewayAssociation resource when available.

    VPC Attachment Association

    For VPC attachments, always reference the attachment resource’s id attribute directly. Avoid using data sources or lifecycle rules that might cause the attachment ID to become unknown during planning:

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const example = new aws.ec2.Vpc("example", {cidrBlock: "10.0.0.0/16"});
    const exampleSubnet = new aws.ec2.Subnet("example", {
        vpcId: example.id,
        cidrBlock: "10.0.1.0/24",
    });
    const exampleTransitGateway = new aws.ec2transitgateway.TransitGateway("example", {description: "example"});
    const exampleVpcAttachment = new aws.ec2transitgateway.VpcAttachment("example", {
        subnetIds: [exampleSubnet.id],
        transitGatewayId: exampleTransitGateway.id,
        vpcId: example.id,
    });
    const exampleRouteTable = new aws.ec2transitgateway.RouteTable("example", {transitGatewayId: exampleTransitGateway.id});
    // Correct: Reference the VPC attachment ID directly
    const exampleRouteTableAssociation = new aws.ec2transitgateway.RouteTableAssociation("example", {
        transitGatewayAttachmentId: exampleVpcAttachment.id,
        transitGatewayRouteTableId: exampleRouteTable.id,
    });
    
    import pulumi
    import pulumi_aws as aws
    
    example = aws.ec2.Vpc("example", cidr_block="10.0.0.0/16")
    example_subnet = aws.ec2.Subnet("example",
        vpc_id=example.id,
        cidr_block="10.0.1.0/24")
    example_transit_gateway = aws.ec2transitgateway.TransitGateway("example", description="example")
    example_vpc_attachment = aws.ec2transitgateway.VpcAttachment("example",
        subnet_ids=[example_subnet.id],
        transit_gateway_id=example_transit_gateway.id,
        vpc_id=example.id)
    example_route_table = aws.ec2transitgateway.RouteTable("example", transit_gateway_id=example_transit_gateway.id)
    # Correct: Reference the VPC attachment ID directly
    example_route_table_association = aws.ec2transitgateway.RouteTableAssociation("example",
        transit_gateway_attachment_id=example_vpc_attachment.id,
        transit_gateway_route_table_id=example_route_table.id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/ec2"
    	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/ec2transitgateway"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		example, err := ec2.NewVpc(ctx, "example", &ec2.VpcArgs{
    			CidrBlock: pulumi.String("10.0.0.0/16"),
    		})
    		if err != nil {
    			return err
    		}
    		exampleSubnet, err := ec2.NewSubnet(ctx, "example", &ec2.SubnetArgs{
    			VpcId:     example.ID(),
    			CidrBlock: pulumi.String("10.0.1.0/24"),
    		})
    		if err != nil {
    			return err
    		}
    		exampleTransitGateway, err := ec2transitgateway.NewTransitGateway(ctx, "example", &ec2transitgateway.TransitGatewayArgs{
    			Description: pulumi.String("example"),
    		})
    		if err != nil {
    			return err
    		}
    		exampleVpcAttachment, err := ec2transitgateway.NewVpcAttachment(ctx, "example", &ec2transitgateway.VpcAttachmentArgs{
    			SubnetIds: pulumi.StringArray{
    				exampleSubnet.ID(),
    			},
    			TransitGatewayId: exampleTransitGateway.ID(),
    			VpcId:            example.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		exampleRouteTable, err := ec2transitgateway.NewRouteTable(ctx, "example", &ec2transitgateway.RouteTableArgs{
    			TransitGatewayId: exampleTransitGateway.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		// Correct: Reference the VPC attachment ID directly
    		_, err = ec2transitgateway.NewRouteTableAssociation(ctx, "example", &ec2transitgateway.RouteTableAssociationArgs{
    			TransitGatewayAttachmentId: exampleVpcAttachment.ID(),
    			TransitGatewayRouteTableId: exampleRouteTable.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var example = new Aws.Ec2.Vpc("example", new()
        {
            CidrBlock = "10.0.0.0/16",
        });
    
        var exampleSubnet = new Aws.Ec2.Subnet("example", new()
        {
            VpcId = example.Id,
            CidrBlock = "10.0.1.0/24",
        });
    
        var exampleTransitGateway = new Aws.Ec2TransitGateway.TransitGateway("example", new()
        {
            Description = "example",
        });
    
        var exampleVpcAttachment = new Aws.Ec2TransitGateway.VpcAttachment("example", new()
        {
            SubnetIds = new[]
            {
                exampleSubnet.Id,
            },
            TransitGatewayId = exampleTransitGateway.Id,
            VpcId = example.Id,
        });
    
        var exampleRouteTable = new Aws.Ec2TransitGateway.RouteTable("example", new()
        {
            TransitGatewayId = exampleTransitGateway.Id,
        });
    
        // Correct: Reference the VPC attachment ID directly
        var exampleRouteTableAssociation = new Aws.Ec2TransitGateway.RouteTableAssociation("example", new()
        {
            TransitGatewayAttachmentId = exampleVpcAttachment.Id,
            TransitGatewayRouteTableId = exampleRouteTable.Id,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.ec2.Vpc;
    import com.pulumi.aws.ec2.VpcArgs;
    import com.pulumi.aws.ec2.Subnet;
    import com.pulumi.aws.ec2.SubnetArgs;
    import com.pulumi.aws.ec2transitgateway.TransitGateway;
    import com.pulumi.aws.ec2transitgateway.TransitGatewayArgs;
    import com.pulumi.aws.ec2transitgateway.VpcAttachment;
    import com.pulumi.aws.ec2transitgateway.VpcAttachmentArgs;
    import com.pulumi.aws.ec2transitgateway.RouteTable;
    import com.pulumi.aws.ec2transitgateway.RouteTableArgs;
    import com.pulumi.aws.ec2transitgateway.RouteTableAssociation;
    import com.pulumi.aws.ec2transitgateway.RouteTableAssociationArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var example = new Vpc("example", VpcArgs.builder()
                .cidrBlock("10.0.0.0/16")
                .build());
    
            var exampleSubnet = new Subnet("exampleSubnet", SubnetArgs.builder()
                .vpcId(example.id())
                .cidrBlock("10.0.1.0/24")
                .build());
    
            var exampleTransitGateway = new TransitGateway("exampleTransitGateway", TransitGatewayArgs.builder()
                .description("example")
                .build());
    
            var exampleVpcAttachment = new VpcAttachment("exampleVpcAttachment", VpcAttachmentArgs.builder()
                .subnetIds(exampleSubnet.id())
                .transitGatewayId(exampleTransitGateway.id())
                .vpcId(example.id())
                .build());
    
            var exampleRouteTable = new RouteTable("exampleRouteTable", RouteTableArgs.builder()
                .transitGatewayId(exampleTransitGateway.id())
                .build());
    
            // Correct: Reference the VPC attachment ID directly
            var exampleRouteTableAssociation = new RouteTableAssociation("exampleRouteTableAssociation", RouteTableAssociationArgs.builder()
                .transitGatewayAttachmentId(exampleVpcAttachment.id())
                .transitGatewayRouteTableId(exampleRouteTable.id())
                .build());
    
        }
    }
    
    resources:
      example:
        type: aws:ec2:Vpc
        properties:
          cidrBlock: 10.0.0.0/16
      exampleSubnet:
        type: aws:ec2:Subnet
        name: example
        properties:
          vpcId: ${example.id}
          cidrBlock: 10.0.1.0/24
      exampleTransitGateway:
        type: aws:ec2transitgateway:TransitGateway
        name: example
        properties:
          description: example
      exampleVpcAttachment:
        type: aws:ec2transitgateway:VpcAttachment
        name: example
        properties:
          subnetIds:
            - ${exampleSubnet.id}
          transitGatewayId: ${exampleTransitGateway.id}
          vpcId: ${example.id}
      exampleRouteTable:
        type: aws:ec2transitgateway:RouteTable
        name: example
        properties:
          transitGatewayId: ${exampleTransitGateway.id}
      # Correct: Reference the VPC attachment ID directly
      exampleRouteTableAssociation:
        type: aws:ec2transitgateway:RouteTableAssociation
        name: example
        properties:
          transitGatewayAttachmentId: ${exampleVpcAttachment.id}
          transitGatewayRouteTableId: ${exampleRouteTable.id}
    

    NOTE: When the transit_gateway_attachment_id changes (for example, when a VPC attachment is replaced), this resource will be recreated. This is the correct behavior to maintain consistency between the attachment and its route table association.

    Create RouteTableAssociation Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new RouteTableAssociation(name: string, args: RouteTableAssociationArgs, opts?: CustomResourceOptions);
    @overload
    def RouteTableAssociation(resource_name: str,
                              args: RouteTableAssociationArgs,
                              opts: Optional[ResourceOptions] = None)
    
    @overload
    def RouteTableAssociation(resource_name: str,
                              opts: Optional[ResourceOptions] = None,
                              transit_gateway_attachment_id: Optional[str] = None,
                              transit_gateway_route_table_id: Optional[str] = None,
                              region: Optional[str] = None,
                              replace_existing_association: Optional[bool] = None)
    func NewRouteTableAssociation(ctx *Context, name string, args RouteTableAssociationArgs, opts ...ResourceOption) (*RouteTableAssociation, error)
    public RouteTableAssociation(string name, RouteTableAssociationArgs args, CustomResourceOptions? opts = null)
    public RouteTableAssociation(String name, RouteTableAssociationArgs args)
    public RouteTableAssociation(String name, RouteTableAssociationArgs args, CustomResourceOptions options)
    
    type: aws:ec2transitgateway:RouteTableAssociation
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args RouteTableAssociationArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args RouteTableAssociationArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args RouteTableAssociationArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args RouteTableAssociationArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args RouteTableAssociationArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var awsRouteTableAssociationResource = new Aws.Ec2TransitGateway.RouteTableAssociation("awsRouteTableAssociationResource", new()
    {
        TransitGatewayAttachmentId = "string",
        TransitGatewayRouteTableId = "string",
        Region = "string",
        ReplaceExistingAssociation = false,
    });
    
    example, err := ec2transitgateway.NewRouteTableAssociation(ctx, "awsRouteTableAssociationResource", &ec2transitgateway.RouteTableAssociationArgs{
    	TransitGatewayAttachmentId: pulumi.String("string"),
    	TransitGatewayRouteTableId: pulumi.String("string"),
    	Region:                     pulumi.String("string"),
    	ReplaceExistingAssociation: pulumi.Bool(false),
    })
    
    var awsRouteTableAssociationResource = new com.pulumi.aws.ec2transitgateway.RouteTableAssociation("awsRouteTableAssociationResource", com.pulumi.aws.ec2transitgateway.RouteTableAssociationArgs.builder()
        .transitGatewayAttachmentId("string")
        .transitGatewayRouteTableId("string")
        .region("string")
        .replaceExistingAssociation(false)
        .build());
    
    aws_route_table_association_resource = aws.ec2transitgateway.RouteTableAssociation("awsRouteTableAssociationResource",
        transit_gateway_attachment_id="string",
        transit_gateway_route_table_id="string",
        region="string",
        replace_existing_association=False)
    
    const awsRouteTableAssociationResource = new aws.ec2transitgateway.RouteTableAssociation("awsRouteTableAssociationResource", {
        transitGatewayAttachmentId: "string",
        transitGatewayRouteTableId: "string",
        region: "string",
        replaceExistingAssociation: false,
    });
    
    type: aws:ec2transitgateway:RouteTableAssociation
    properties:
        region: string
        replaceExistingAssociation: false
        transitGatewayAttachmentId: string
        transitGatewayRouteTableId: string
    

    RouteTableAssociation Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The RouteTableAssociation resource accepts the following input properties:

    TransitGatewayAttachmentId string
    Identifier of EC2 Transit Gateway Attachment.
    TransitGatewayRouteTableId string
    Identifier of EC2 Transit Gateway Route Table.
    Region string
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    ReplaceExistingAssociation bool
    Boolean whether the Gateway Attachment should remove any current Route Table association before associating with the specified Route Table. Default value: false. This argument is intended for use with EC2 Transit Gateways shared into the current account, otherwise the transit_gateway_default_route_table_association argument of the aws.ec2transitgateway.VpcAttachment resource should be used.
    TransitGatewayAttachmentId string
    Identifier of EC2 Transit Gateway Attachment.
    TransitGatewayRouteTableId string
    Identifier of EC2 Transit Gateway Route Table.
    Region string
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    ReplaceExistingAssociation bool
    Boolean whether the Gateway Attachment should remove any current Route Table association before associating with the specified Route Table. Default value: false. This argument is intended for use with EC2 Transit Gateways shared into the current account, otherwise the transit_gateway_default_route_table_association argument of the aws.ec2transitgateway.VpcAttachment resource should be used.
    transitGatewayAttachmentId String
    Identifier of EC2 Transit Gateway Attachment.
    transitGatewayRouteTableId String
    Identifier of EC2 Transit Gateway Route Table.
    region String
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    replaceExistingAssociation Boolean
    Boolean whether the Gateway Attachment should remove any current Route Table association before associating with the specified Route Table. Default value: false. This argument is intended for use with EC2 Transit Gateways shared into the current account, otherwise the transit_gateway_default_route_table_association argument of the aws.ec2transitgateway.VpcAttachment resource should be used.
    transitGatewayAttachmentId string
    Identifier of EC2 Transit Gateway Attachment.
    transitGatewayRouteTableId string
    Identifier of EC2 Transit Gateway Route Table.
    region string
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    replaceExistingAssociation boolean
    Boolean whether the Gateway Attachment should remove any current Route Table association before associating with the specified Route Table. Default value: false. This argument is intended for use with EC2 Transit Gateways shared into the current account, otherwise the transit_gateway_default_route_table_association argument of the aws.ec2transitgateway.VpcAttachment resource should be used.
    transit_gateway_attachment_id str
    Identifier of EC2 Transit Gateway Attachment.
    transit_gateway_route_table_id str
    Identifier of EC2 Transit Gateway Route Table.
    region str
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    replace_existing_association bool
    Boolean whether the Gateway Attachment should remove any current Route Table association before associating with the specified Route Table. Default value: false. This argument is intended for use with EC2 Transit Gateways shared into the current account, otherwise the transit_gateway_default_route_table_association argument of the aws.ec2transitgateway.VpcAttachment resource should be used.
    transitGatewayAttachmentId String
    Identifier of EC2 Transit Gateway Attachment.
    transitGatewayRouteTableId String
    Identifier of EC2 Transit Gateway Route Table.
    region String
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    replaceExistingAssociation Boolean
    Boolean whether the Gateway Attachment should remove any current Route Table association before associating with the specified Route Table. Default value: false. This argument is intended for use with EC2 Transit Gateways shared into the current account, otherwise the transit_gateway_default_route_table_association argument of the aws.ec2transitgateway.VpcAttachment resource should be used.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the RouteTableAssociation resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    ResourceId string
    Identifier of the resource
    ResourceType string
    Type of the resource
    Id string
    The provider-assigned unique ID for this managed resource.
    ResourceId string
    Identifier of the resource
    ResourceType string
    Type of the resource
    id String
    The provider-assigned unique ID for this managed resource.
    resourceId String
    Identifier of the resource
    resourceType String
    Type of the resource
    id string
    The provider-assigned unique ID for this managed resource.
    resourceId string
    Identifier of the resource
    resourceType string
    Type of the resource
    id str
    The provider-assigned unique ID for this managed resource.
    resource_id str
    Identifier of the resource
    resource_type str
    Type of the resource
    id String
    The provider-assigned unique ID for this managed resource.
    resourceId String
    Identifier of the resource
    resourceType String
    Type of the resource

    Look up Existing RouteTableAssociation Resource

    Get an existing RouteTableAssociation resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: RouteTableAssociationState, opts?: CustomResourceOptions): RouteTableAssociation
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            region: Optional[str] = None,
            replace_existing_association: Optional[bool] = None,
            resource_id: Optional[str] = None,
            resource_type: Optional[str] = None,
            transit_gateway_attachment_id: Optional[str] = None,
            transit_gateway_route_table_id: Optional[str] = None) -> RouteTableAssociation
    func GetRouteTableAssociation(ctx *Context, name string, id IDInput, state *RouteTableAssociationState, opts ...ResourceOption) (*RouteTableAssociation, error)
    public static RouteTableAssociation Get(string name, Input<string> id, RouteTableAssociationState? state, CustomResourceOptions? opts = null)
    public static RouteTableAssociation get(String name, Output<String> id, RouteTableAssociationState state, CustomResourceOptions options)
    resources:  _:    type: aws:ec2transitgateway:RouteTableAssociation    get:      id: ${id}
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    Region string
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    ReplaceExistingAssociation bool
    Boolean whether the Gateway Attachment should remove any current Route Table association before associating with the specified Route Table. Default value: false. This argument is intended for use with EC2 Transit Gateways shared into the current account, otherwise the transit_gateway_default_route_table_association argument of the aws.ec2transitgateway.VpcAttachment resource should be used.
    ResourceId string
    Identifier of the resource
    ResourceType string
    Type of the resource
    TransitGatewayAttachmentId string
    Identifier of EC2 Transit Gateway Attachment.
    TransitGatewayRouteTableId string
    Identifier of EC2 Transit Gateway Route Table.
    Region string
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    ReplaceExistingAssociation bool
    Boolean whether the Gateway Attachment should remove any current Route Table association before associating with the specified Route Table. Default value: false. This argument is intended for use with EC2 Transit Gateways shared into the current account, otherwise the transit_gateway_default_route_table_association argument of the aws.ec2transitgateway.VpcAttachment resource should be used.
    ResourceId string
    Identifier of the resource
    ResourceType string
    Type of the resource
    TransitGatewayAttachmentId string
    Identifier of EC2 Transit Gateway Attachment.
    TransitGatewayRouteTableId string
    Identifier of EC2 Transit Gateway Route Table.
    region String
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    replaceExistingAssociation Boolean
    Boolean whether the Gateway Attachment should remove any current Route Table association before associating with the specified Route Table. Default value: false. This argument is intended for use with EC2 Transit Gateways shared into the current account, otherwise the transit_gateway_default_route_table_association argument of the aws.ec2transitgateway.VpcAttachment resource should be used.
    resourceId String
    Identifier of the resource
    resourceType String
    Type of the resource
    transitGatewayAttachmentId String
    Identifier of EC2 Transit Gateway Attachment.
    transitGatewayRouteTableId String
    Identifier of EC2 Transit Gateway Route Table.
    region string
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    replaceExistingAssociation boolean
    Boolean whether the Gateway Attachment should remove any current Route Table association before associating with the specified Route Table. Default value: false. This argument is intended for use with EC2 Transit Gateways shared into the current account, otherwise the transit_gateway_default_route_table_association argument of the aws.ec2transitgateway.VpcAttachment resource should be used.
    resourceId string
    Identifier of the resource
    resourceType string
    Type of the resource
    transitGatewayAttachmentId string
    Identifier of EC2 Transit Gateway Attachment.
    transitGatewayRouteTableId string
    Identifier of EC2 Transit Gateway Route Table.
    region str
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    replace_existing_association bool
    Boolean whether the Gateway Attachment should remove any current Route Table association before associating with the specified Route Table. Default value: false. This argument is intended for use with EC2 Transit Gateways shared into the current account, otherwise the transit_gateway_default_route_table_association argument of the aws.ec2transitgateway.VpcAttachment resource should be used.
    resource_id str
    Identifier of the resource
    resource_type str
    Type of the resource
    transit_gateway_attachment_id str
    Identifier of EC2 Transit Gateway Attachment.
    transit_gateway_route_table_id str
    Identifier of EC2 Transit Gateway Route Table.
    region String
    Region where this resource will be managed. Defaults to the Region set in the provider configuration.
    replaceExistingAssociation Boolean
    Boolean whether the Gateway Attachment should remove any current Route Table association before associating with the specified Route Table. Default value: false. This argument is intended for use with EC2 Transit Gateways shared into the current account, otherwise the transit_gateway_default_route_table_association argument of the aws.ec2transitgateway.VpcAttachment resource should be used.
    resourceId String
    Identifier of the resource
    resourceType String
    Type of the resource
    transitGatewayAttachmentId String
    Identifier of EC2 Transit Gateway Attachment.
    transitGatewayRouteTableId String
    Identifier of EC2 Transit Gateway Route Table.

    Import

    Using pulumi import, import aws_ec2_transit_gateway_route_table_association using the EC2 Transit Gateway Route Table identifier, an underscore, and the EC2 Transit Gateway Attachment identifier. For example:

    $ pulumi import aws:ec2transitgateway/routeTableAssociation:RouteTableAssociation example tgw-rtb-12345678_tgw-attach-87654321
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    AWS Classic pulumi/pulumi-aws
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the aws Terraform Provider.
    aws logo
    AWS v7.10.0 published on Friday, Oct 24, 2025 by Pulumi
      Meet Neo: Your AI Platform Teammate