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년 전564회 조회
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년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠