How to include existing AWS::EC2::Route and AWS::EC2::VPCGatewayAttachment resources in CloudFormation template?

0

I am building CloudFormation templates to support the ability for others to recreate an existing VPC, along with its VPC peering connection, a virtual private gateway, route tables, and public subnets, and the supporting routes. I built a template that reflects all this, but when I tried to import it, I discovered that some resources were unable to be imported. Specifically, the AWS::EC2::Route and AWS::EC2::VPCGatewayAttachment types. So I created a base template without those resources for now, which works in the near term since those routes and gateway attachments exist as deployed.

My concern is if we have to shut down, modify, or recreate this environment again down the road. I want to ensure that my new stack reflects these missing resources. However, I'm not entirely sure the best way to approach it without deleting the routes and disassociating the gateways and recreating them as a change set.

It occurs to me that perhaps I could include the missing resources and submit the complete template as a new change set, but my assumption is that it will either fail and roll back, or succeed and create duplicates somehow. I am also worried that it could get confused, taking down those gateways and introduce connectivity issues for others on the team.

I assume there is a best practice that I should follow here, but I haven't come across this issue before. I welcome suggestions.

Thanks!

1 Answer
0

AWS::EC2::Route" and "AWS::EC2::VPCGatewayAttachment" are not listed in the following documentation, so you are correct that resource import is not supported.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resource-import-supported-resources.html

If you don't want to affect the existing stack, how about creating "AWS::EC2::Route" and "AWS::EC2::VPCGatewayAttachment" on separate stacks?
After creation, if there are no problems, it would be better to edit the existing stack by importing it into the existing stack.

It would be difficult to delete the routes and unassociate the gateways without recreating them as a change set.
If you do not delete it, you will probably get an "already exists" error and the stack update will fail.

profile picture
EXPERT
answered a year 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