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.

質問済み 2年前548ビュー
2回答
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
エキスパート
回答済み 2年前
0

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

profile pictureAWS
エキスパート
kentrad
回答済み 2年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ