1

I created the stack using amazon cloudformation in yaml.

• VPC with 4 Subnets (2 Public and 2 Private).

• Each public and private subnets were placed in the AZ ap-south-1a (1 public, 1 private and in ap-south-1b (1 public and 1 private).

• Created Route Tables for public and private subnets.

• Tried associating the the public subnets of 1a and 1b to the public RT but it doesn't worked. but if i associate 1 subnet to this public rt it does work.

How to associate multiple subnets to a route table using cloudformation (yaml)?

Thank in advance.

CFPublicRT: Type: AWS::EC2::RouteTable Properties: Tags: - Key: Name Value: Public RT VpcId: !Ref CFVPC CFPrivateRT: Type: AWS::EC2::RouteTable Properties: Tags: - Key: Name Value: Private RT VpcId: !Ref CFVPC routetablepublicsubnetassociation: Type: AWS::EC2::SubnetRouteTableAssociation Properties: RouteTableId: !Ref CFPublicRT SubnetId: !Ref CFPublicSubnet1a routetableprivatesubnetassociation: Type: AWS::EC2::SubnetRouteTableAssociation Properties: RouteTableId: !Ref CFPrivateRT SubnetId: !Ref CFPrivateSubnet1a 

1 Answer 1

3

You can use something like this:

SubnetARouteTableAssociation: Type: AWS::EC2::SubnetRouteTableAssociation Properties: RouteTableId: !Ref RouteTablePublic SubnetId: !Ref PublicSubnetA SubnetBRouteTableAssociation: Type: AWS::EC2::SubnetRouteTableAssociation Properties: RouteTableId: !Ref RouteTablePublic SubnetId: !Ref PublicSubnetB SubnetCRouteTableAssociation: Type: AWS::EC2::SubnetRouteTableAssociation Properties: RouteTableId: !Ref RouteTablePrivate SubnetId: !Ref PrivateSubnetC SubnetDRouteTableAssociation: Type: AWS::EC2::SubnetRouteTableAssociation Properties: RouteTableId: !Ref RouteTablePrivate SubnetId: !Ref PrivateSubnetD 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.