-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Description
Describe the feature
On Nov 17 2023, a new feature was announced: AWS CloudFormation simplifies resource import with a new parameter for ChangeSets.
https://aws.amazon.com/about-aws/whats-new/2023/11/aws-cloudformation-import-parameter-changesets/
Summary:
AWS CloudFormation's new ImportExistingResources parameter for CreateChangeSet API automatically imports existing resources in the template during deployments. It identifies resources using custom names, avoiding errors from naming conflicts. This reduces manual effort as a separate resource name document is no longer needed. ImportExistingResources allows importing existing resources and deploying changes in a single ChangeSet.
Use Case
Automatically import exsting resources with the same physical name, such as S3 bucket, DDB table, etc, during a CFn deployment.
Because resource import is a vital feature for CDK users e.g. to refactor a construct tree, it would benefit many potential users if cdk natively support it.
Proposed Solution
This feature introduced a new request parameter ImportExstingResources to the CreateChangeSet API. So I guess we can add a CLI option like --import-exsting-resources: boolean to cdk deploy command to enable the new feature.
The API is called here:
aws-cdk/packages/aws-cdk/lib/api/deploy-stack.ts
Lines 410 to 418 in c66e197
| const changeSet = await this.cfn.createChangeSet({ | |
| StackName: this.stackName, | |
| ChangeSetName: changeSetName, | |
| ChangeSetType: this.options.resourcesToImport ? 'IMPORT' : this.update ? 'UPDATE' : 'CREATE', | |
| ResourcesToImport: this.options.resourcesToImport, | |
| Description: `CDK Changeset for execution ${this.uuid}`, | |
| ClientToken: `create${this.uuid}`, | |
| ...this.commonPrepareOptions(), | |
| }).promise(); |
Other Information
No response
Acknowledgements
- I may be able to implement this feature request
- This feature might incur a breaking change
CDK version used
2.110.0
Environment details (OS name and version, etc.)
macOS