Create Route via Cloudformation Template

0

Hi, I am trying to attach route table to a subnet via cloudformation template. I want to add a hypothetical route of say 172.31.0.0/24 to a EC2 instance. Is it possible to add this route via cloudformation? I cant see anything as such on docs.

Please help me point to right direction. There are Cloudformation things like AWS::EC2::Route and AWS::EC2::RouteTable but these doesnt seem to allow specific routes in cloudformation.

asked 3 years ago664 views
2 Answers
2

Your question is a little unclear: Are you trying to add a route to the EC2 instance (i.e. the operating system) or are you trying to add a route to the VPC that points to an instance?

If the latter, you can definitely use AWS::EC2::Route to do that as one of the targets is the instance id. The route is then associated with a route table.

If the former (trying to add a route to the OS) - CloudFormation won't help you here as it doesn't provide configuration for operating systems of instances. However, what you could do is create UserData for the instance which would create the route on instance startup. However, UserData is only executed at first launch so this is not going to help with an instance that is already launched.

Normally though, adding routes to the VPC is good enough because the instance sends traffic to the VPC "router" and it sends traffic to the appropriate destination.

profile pictureAWS
EXPERT
answered 3 years ago
0

To attach a route table to a subnet, where the EC2 instance resides, see AWS::EC2::SubnetRouteTableAssociation.

profile pictureAWS
EXPERT
kentrad
answered 3 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions