-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Description
When invoking cdk deploy with the --no-execute flag, CDK will create a changeset whose name is completely random. Usually this might be okay, but in automated environments this is unacceptable. As such, it should be possible to provide a name which CDK will use when creating a changeset (e.g. using a --change-set-name <string> flag).
Use Case
Our CI/CD environment runs on top of CodePipeline in combination with CodeBuild (and very extensive use of CDK). Naturally, our initial approach was to simply do a cdk deploy inside our CodeBuild containers. However, the stack creation/update itself often takes several minutes with the computing instance just waiting for the stack create to finish. This is not very cost-efficient.
So, to save resources and costs, the CodeBuild containers should not execute the changeset, only create it so that CodePipeline's CloudFormationExecuteChangeSetAction can take over. However, this specific deploy action needs the changeset name which must be known at create time (the Fn::GetParam function unfortunately only works for TemplateOverrides, tried that already).
Proposed Solution
I believe the solution is simple: the CLI should accept a --change-set-name <string> option, and pass this optional parameter to the deployStack function. This one should use the parameter, if provided, or fallback to the existing uuid.v4() method. This can also be used in combination with --execute, but there it will be significantly less interesting.
Other
For our use case... we tried going with cdk synth and CreateStackAction shenanigans, but this leads to many more problems:
- we have lots of assets which will not get uploaded in
cdk synth, so we'd have to do it all manually or introduce the cdk-assets package. - CodePipeline uses some other role for the stack than CDK (which is hard to override without diving into CDK internals) and since we have KMS encrypted S3 buckets, this approach led to many hard-to-debug S3 API errors.
- you cannot provide
NotificationArnswith this approach which are also used by us
- 👋 I may be able to implement this feature request
This is a 🚀 Feature Request