RouteTableAssociation

Provides a resource to create an association between a route table and a subnet or a route table and an internet gateway or virtual private gateway.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var routeTableAssociation = new Aws.Ec2.RouteTableAssociation("routeTableAssociation", new Aws.Ec2.RouteTableAssociationArgs
        {
            SubnetId = aws_subnet.Foo.Id,
            RouteTableId = aws_route_table.Bar.Id,
        });
    }

}
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v4/go/aws/ec2"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := ec2.NewRouteTableAssociation(ctx, "routeTableAssociation", &ec2.RouteTableAssociationArgs{
			SubnetId:     pulumi.Any(aws_subnet.Foo.Id),
			RouteTableId: pulumi.Any(aws_route_table.Bar.Id),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
import pulumi
import pulumi_aws as aws

route_table_association = aws.ec2.RouteTableAssociation("routeTableAssociation",
    subnet_id=aws_subnet["foo"]["id"],
    route_table_id=aws_route_table["bar"]["id"])
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const routeTableAssociation = new aws.ec2.RouteTableAssociation("routeTableAssociation", {
    subnetId: aws_subnet.foo.id,
    routeTableId: aws_route_table.bar.id,
});

Create a RouteTableAssociation Resource

new RouteTableAssociation(name: string, args: RouteTableAssociationArgs, opts?: CustomResourceOptions);
@overload
def RouteTableAssociation(resource_name: str,
                          opts: Optional[ResourceOptions] = None,
                          gateway_id: Optional[str] = None,
                          route_table_id: Optional[str] = None,
                          subnet_id: Optional[str] = None)
@overload
def RouteTableAssociation(resource_name: str,
                          args: RouteTableAssociationArgs,
                          opts: Optional[ResourceOptions] = None)
func NewRouteTableAssociation(ctx *Context, name string, args RouteTableAssociationArgs, opts ...ResourceOption) (*RouteTableAssociation, error)
public RouteTableAssociation(string name, RouteTableAssociationArgs args, CustomResourceOptions? opts = null)
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.

RouteTableAssociation Resource Properties

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

Inputs

The RouteTableAssociation resource accepts the following input properties:

RouteTableId string
The ID of the routing table to associate with.
GatewayId string
The gateway ID to create an association. Conflicts with subnet_id.
SubnetId string
The subnet ID to create an association. Conflicts with gateway_id.
RouteTableId string
The ID of the routing table to associate with.
GatewayId string
The gateway ID to create an association. Conflicts with subnet_id.
SubnetId string
The subnet ID to create an association. Conflicts with gateway_id.
routeTableId string
The ID of the routing table to associate with.
gatewayId string
The gateway ID to create an association. Conflicts with subnet_id.
subnetId string
The subnet ID to create an association. Conflicts with gateway_id.
route_table_id str
The ID of the routing table to associate with.
gateway_id str
The gateway ID to create an association. Conflicts with subnet_id.
subnet_id str
The subnet ID to create an association. Conflicts with gateway_id.

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.
Id string
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.

Look up an 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,
        gateway_id: Optional[str] = None,
        route_table_id: Optional[str] = None,
        subnet_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)
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.

The following state arguments are supported:

GatewayId string
The gateway ID to create an association. Conflicts with subnet_id.
RouteTableId string
The ID of the routing table to associate with.
SubnetId string
The subnet ID to create an association. Conflicts with gateway_id.
GatewayId string
The gateway ID to create an association. Conflicts with subnet_id.
RouteTableId string
The ID of the routing table to associate with.
SubnetId string
The subnet ID to create an association. Conflicts with gateway_id.
gatewayId string
The gateway ID to create an association. Conflicts with subnet_id.
routeTableId string
The ID of the routing table to associate with.
subnetId string
The subnet ID to create an association. Conflicts with gateway_id.
gateway_id str
The gateway ID to create an association. Conflicts with subnet_id.
route_table_id str
The ID of the routing table to associate with.
subnet_id str
The subnet ID to create an association. Conflicts with gateway_id.

Import

is already associated, will result in an error (e.g., Resource.AlreadyAssociatedthe specified association for route table rtb-4176657279 conflicts with an existing association) unless you first import the original association. EC2 Route Table Associations can be imported using the associated resource ID and Route Table ID separated by a forward slash (/). For example with EC2 Subnets

 $ pulumi import aws:ec2/routeTableAssociation:RouteTableAssociation assoc subnet-6777656e646f6c796e/rtb-656c65616e6f72

For example with EC2 Internet Gateways

 $ pulumi import aws:ec2/routeTableAssociation:RouteTableAssociation assoc igw-01b3a60780f8d034a/rtb-656c65616e6f72

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.