AWS CloudFormation
User Guide (Version )

AWS::EC2::SubnetRouteTableAssociation

Associates a subnet with a route table. The subnet and route table must be in the same VPC. This association causes traffic originating from the subnet to be routed according to the routes in the route table. A route table can be associated with multiple subnets.

Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

JSON

{ "Type" : "AWS::EC2::SubnetRouteTableAssociation", "Properties" : { "RouteTableId" : String, "SubnetId" : String } }

YAML

Type: AWS::EC2::SubnetRouteTableAssociation Properties: RouteTableId: String SubnetId: String

Properties

RouteTableId

The ID of the route table.

The physical ID changes when the route table ID is changed.

Required: Yes

Type: String

Update requires: No interruption

SubnetId

The ID of the subnet.

Required: Yes

Type: String

Update requires: Replacement

Return Values

Ref

When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the name of the subnet route table association.

For more information about using the Ref function, see Ref.

Examples

Subnet Route Table Association

The following example associates a subnet with a route table.

JSON

"mySubnetRouteTableAssociation" : { "Type" : "AWS::EC2::SubnetRouteTableAssociation", "Properties" : { "SubnetId" : { "Ref" : "mySubnet" }, "RouteTableId" : { "Ref" : "myRouteTable" } } }

YAML

mySubnetRouteTableAssociation: Type: AWS::EC2::SubnetRouteTableAssociation Properties: SubnetId: Ref: mySubnet RouteTableId: Ref: myRouteTable

See Also