AWS::EC2::SubnetRouteTableAssociation
Associates a subnet with a route table.
When AWS::EC2::SubnetRouteTableAssociation
resources are created during create or update operations, AWS CloudFormation adopts
existing resources that share the same key
properties (the properties that contribute to uniquely identify the resource).
However, if the operation fails and rolls back, AWS CloudFormation deletes the previously
out-of-band resources.
You can protect against this behavior by using Retain deletion policies. For more information, see
DeletionPolicy Attribute.
Topics
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:StringSubnetId: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:
"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:
"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:
{ "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
{ "AWSTemplateFormatVersion" : "2010-09-09", "Resources" : { "mySubnetRouteTableAssociation" : { "Type" : "AWS::EC2::SubnetRouteTableAssociation", "Properties" : { "SubnetId" : { "Ref" : "mySubnet" }, "RouteTableId" : { "Ref" : "myRouteTable" } } } } }
YAML
AWSTemplateFormatVersion: '2010-09-09' Resources: mySubnetRouteTableAssociation: Type: AWS::EC2::SubnetRouteTableAssociation Properties: SubnetId: Ref: mySubnet RouteTableId: Ref: myRouteTable
See Also
-
AssociateRouteTable in the Amazon EC2 API Reference
