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. To create a route table, see AWS::EC2::RouteTable.
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: Replacement
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 ID of the subnet route table association.
For more information about using the Ref
function, see Ref
.
Fn::GetAtt
The Fn::GetAtt
intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.
For more information about using the Fn::GetAtt
intrinsic function, see Fn::GetAtt
.
Id
-
The ID of the subnet route table association.
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
-
AssociateRouteTable in the Amazon EC2 API Reference
-
Route tables in the Amazon VPC User Guide