Skip to content

cli: support CloudFormation simplified resource import #28060

@tmokmss

Description

@tmokmss

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:

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

Metadata

Metadata

Assignees

Labels

effort/mediumMedium work item – several days of effortfeature-requestA feature should be added or improved.p1package/toolsRelated to AWS CDK Tools or CLI

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions