Menu
AWS CloudFormation
User Guide (API Version 2010-05-15)

AWS::EC2::SubnetRouteTableAssociation

Associates a subnet with a route table.

Syntax

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

JSON

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

YAML

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

Properties

RouteTableId

The ID of the route table. This is commonly written as a reference to a route table declared elsewhere in the template. For example:

Copy
"RouteTableId" : { "Ref" : "myRouteTable" }

Required: Yes

Type: String

Update requires: No interruption. However, the physical ID changes when the route table ID is changed.

SubnetId

The ID of the subnet. This is commonly written as a reference to a subnet declared elsewhere in the template. For example:

Copy
"SubnetId" : { "Ref" : "mySubnet" }

Required: Yes

Type: String

Update requires: Replacement

Return Value

When the logical ID of this resource is provided to the Ref intrinsic function, Ref returns the resource name. For example:

Copy
{ "Ref": "MyRTA" }

For the subnet route table association with the logical ID "MyRTA", Ref will return the AWS resource name.

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

Example

JSON

Copy
{ "AWSTemplateFormatVersion" : "2010-09-09", "Resources" : { "mySubnetRouteTableAssociation" : { "Type" : "AWS::EC2::SubnetRouteTableAssociation", "Properties" : { "SubnetId" : { "Ref" : "mySubnet" }, "RouteTableId" : { "Ref" : "myRouteTable" } } } } }

YAML

Copy
AWSTemplateFormatVersion: '2010-09-09' Resources: mySubnetRouteTableAssociation: Type: AWS::EC2::SubnetRouteTableAssociation Properties: SubnetId: Ref: mySubnet RouteTableId: Ref: myRouteTable

See Also