Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for CloudFormation Resource Import to CFn glue code #36513

Merged
merged 1 commit into from
Aug 31, 2020

Conversation

wjordan
Copy link
Contributor

@wjordan wjordan commented Aug 29, 2020

This update to AWS::CloudFormation makes it possible to import existing resources into a stack using the IMPORT type of the CreateChangeSet API operation.

The implementation defines a new import_resources option to trigger importing resources, derived from the IMPORT_RESOURCES env variable via the stack/adhoc rake tasks.

For example, to import an AWS::EC2::Instance resource with a logical-id of Daemon and an instance id i-0123456789abcdef:

RAILS_ENV=staging bundle exec rake stack:start IMPORT_RESOURCES=Daemon:i-0123456789abcdef

Note the existing limitation of resource imports, which will cause the process to fail if not satisfied:

  • An explicit DeletionPolicy must be specified for imported resources.
  • The newly-imported resources must be the only change in the updated stack template, changes to any other resources are not permitted.

Since resource import is only possible through creating/executing a Change Set, I also had to change the implementation to apply stack updates through ExecuteChangeSet instead of UpdateStack directly, making this a much more substantial change. I added an extra Proceed? [y/n] confirmation dialog to create_or_update (:start rake tasks), so manually running :validate before running :start is now slightly less crucial to prevent accidental changes from being applied.

Set `IMPORT_RESOURCES=[logical-id]:[resource-id]` to specify import resources to be applied for a stack `start` and/or `validate`.
Adds CloudFormation ChangeSet permissions to Daemon IAM Role.
@wjordan
Copy link
Contributor Author

wjordan commented Aug 31, 2020

Merging this now in order to unblock other pending work requiring resource imports, will revert if it introduces any new issues in our CI pipeline.

@wjordan wjordan merged commit 5f2b5dc into staging Aug 31, 2020
@wjordan wjordan deleted the cfn-import branch August 31, 2020 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant