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.

gefragt vor 2 Jahren548 Aufrufe
2 Antworten
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
EXPERTE
beantwortet vor 2 Jahren
0

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

profile pictureAWS
EXPERTE
kentrad
beantwortet vor 2 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen