-
Notifications
You must be signed in to change notification settings - Fork 4k
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
feat(cli): adding new option to cdk deploy
to indicate whether ChangeSet should be executed
#4852
Conversation
I created the option to *NOT* execute the ChangeSet via `cdk deploy`. The flag is called **execute** and by default is set to true. By not providing this flag, the workflow of `cdk deploy` will be the same. If anyone wants to *NOT* execute the ChangeSet, providing the flag `--no-execute` will pass the execution of the ChangeSet. You will be able to see the ChangeSet in AWS CloudFormation Console, validate the resources and discard or execute the ChangeSet. closes aws#4739
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also add some tests - integration tests would also be ideal, but ensure you run the CLI integration tests at a minimum.
await monitor.stop(); | ||
} | ||
debug('Stack %s has completed updating', deployName); | ||
} | ||
return { noOp: false, outputs: await getStackOutputs(cfn, deployName), stackArn: changeSet.StackId! }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clarification: just verifying that this would not count as a noOp as we are still generating a ChangeSet and mutating the state of the stack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I modified this portion of code but it doesn't show as outdated.
I tried to not interfere with the testing scripts for as much as I could. The executeChangeSet method is needed to be called in deploy-stacks.ts
in order for some tests to pass. I think calling cfn.executeChangeSet()
without the promise class. This way the tests will pass successfully without modifying them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a good call not to modify existing tests so we don't mask a potential regression.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree. The fact that tests fail is an indication of a regression, and indeed we've had a regression here where bootstrap stacks failed to execute because "execute" was not passed to it.
cdk deploy
cdk deploy
to indicate whether ChangeSet should be executed
…geSet should be executed I created the option to *NOT* execute the ChangeSet via `cdk deploy`. The flag is called **execute** and by default is set to true. By not providing this flag, the workflow of `cdk deploy` will be the same. If anyone wants to *NOT* execute the ChangeSet, providing the flag `--no-execute` will pass the execution of the ChangeSet. You will be able to see the ChangeSet in AWS CloudFormation Console, validate the resources and discard or execute the ChangeSet. closes aws#4739
# Conflicts: # packages/aws-cdk/bin/cdk.ts # packages/aws-cdk/lib/api/deploy-stack.ts # packages/aws-cdk/lib/cdk-toolkit.ts
Pull request has been modified.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
…geSet should be executed I created the option to *NOT* execute the ChangeSet via `cdk deploy`. The flag is called **execute** and by default is set to true. By not providing this flag, the workflow of `cdk deploy` will be the same. If anyone wants to *NOT* execute the ChangeSet, providing the flag `--no-execute` will pass the execution of the ChangeSet. You will be able to see the ChangeSet in AWS CloudFormation Console, validate the resources and discard or execute the ChangeSet. closes aws#4739
New CLI integration test for testing the flag added. |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
await monitor.stop(); | ||
} | ||
debug('Stack %s has completed updating', deployName); | ||
} | ||
return { noOp: false, outputs: await getStackOutputs(cfn, deployName), stackArn: changeSet.StackId! }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a good call not to modify existing tests so we don't mask a potential regression.
…geSet should be executed I created the option to *NOT* execute the ChangeSet via `cdk deploy`. The flag is called **execute** and by default is set to true. By not providing this flag, the workflow of `cdk deploy` will be the same. If anyone wants to *NOT* execute the ChangeSet, providing the flag `--no-execute` will pass the execution of the ChangeSet. You will be able to see the ChangeSet in AWS CloudFormation Console, validate the resources and discard or execute the ChangeSet. closes aws#4739
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
…geSet should be executed I created the option to *NOT* execute the ChangeSet via `cdk deploy`. The flag is called **execute** and by default is set to true. By not providing this flag, the workflow of `cdk deploy` will be the same. If anyone wants to *NOT* execute the ChangeSet, providing the flag `--no-execute` will pass the execution of the ChangeSet. You will be able to see the ChangeSet in AWS CloudFormation Console, validate the resources and discard or execute the ChangeSet. closes aws#4739
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
…geSet should be executed I created the option to *NOT* execute the ChangeSet via `cdk deploy`. The flag is called **execute** and by default is set to true. By not providing this flag, the workflow of `cdk deploy` will be the same. If anyone wants to *NOT* execute the ChangeSet, providing the flag `--no-execute` will pass the execution of the ChangeSet. You will be able to see the ChangeSet in AWS CloudFormation Console, validate the resources and discard or execute the ChangeSet. closes aws#4739
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request is now being automatically merged. |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
…nto 4295-windows-ecs-support * '4295-windows-ecs-support' of github.com:arhea/aws-cdk: chore(deps-dev): bump @types/lodash from 4.14.146 to 4.14.147 (aws#5021) Revert "fix(assets): support exceptions to exclude patterns (aws#4473)" (aws#5022) chore(deps): bump jsii-pacmak from 0.20.3 to 0.20.5 (aws#5003) chore(deps): bump codemaker from 0.20.3 to 0.20.5 (aws#5007) chore(deps-dev): bump @types/jest from 24.0.22 to 24.0.23 (aws#4993) chore(deps): bump jsii from 0.20.3 to 0.20.5 (aws#5006) chore(deps-dev): bump jsii-diff from 0.20.3 to 0.20.5 (aws#5005) chore(deps): bump jsii-spec from 0.20.3 to 0.20.5 (aws#5008) chore(core): resolve tokens before publishing tree.json (aws#4984) feat(cli): adding new option to `cdk deploy` to indicate whether ChangeSet should be executed (aws#4852) chore: move semantic.yaml to .github/ fix(core): unable to find stack by name using the cli in legacy mode (aws#4998) fix(ecs-patterns): Fix issue related to protocol being passed to target group (aws#4988)
debug('Stack %s has completed updating', deployName); | ||
} else { | ||
debug('Entering no-execute workflow for ChangeSet %s on stack %s', changeSetName, deployName); | ||
cfn.executeChangeSet(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we calling executeChangeSet
here?
await waitForStack(cfn, deployName); | ||
if (monitor) { await monitor.stop(); } | ||
debug('Stack %s has completed updating', deployName); | ||
if (options.execute) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not respect the default of "true" (and caused a regression). If options.execute
is undefined, it evaluates to false.
} | ||
debug('Stack %s has completed updating', deployName); | ||
} else { | ||
debug('Entering no-execute workflow for ChangeSet %s on stack %s', changeSetName, deployName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be printed to the user so they don't think the operation is complete.
@@ -59,6 +59,7 @@ async function parseCommandLineArguments() { | |||
.option('ci', { type: 'boolean', desc: 'Force CI detection. Use --no-ci to disable CI autodetection.', default: process.env.CI !== undefined }) | |||
.option('notification-arns', {type: 'array', desc: 'ARNs of SNS topics that CloudFormation will notify with stack related events', nargs: 1, requiresArg: true}) | |||
.option('tags', { type: 'array', alias: 't', desc: 'Tags to add to the stack (KEY=VALUE)', nargs: 1, requiresArg: true })) | |||
.option('execute', {type: 'boolean', desc: 'Whether to execute ChangeSet (--no-execute will NOT execute the ChangeSet)', default: true}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This switch is not defined only for deploy
(despite the indentation). See that the closing )
do not match?
Another issue is that the integ test is not actually working. Fails successfully with:
|
The change that introduced the `--no-execute` feature (#4852) did not take into account that `cdk bootstrap` uses the same code path for deployment, and therefore `execute` was undefined, and resolved to false (despite the documented default). This change moves `execute` switch from the global scope into `deploy` and to `bootstrap` and passes it into the `cliBootstrap` command, as well as respects the default in case the option passed to the deployment utility is `undefined`. It also emits a message to STDOUT in case `--no-execute` is provided to let user know that deployment hasn't really finished. Otherwise, it appears as if deployment is successful. The `deploy-no-execute` integration test was also "failing successfully" due to invalid usage of bash conditions, so this is also fixed here. Added integration test to verify that --no-execute is respected by `cdk bootstrap`.
The change that introduced the `--no-execute` feature (#4852) did not take into account that `cdk bootstrap` uses the same code path for deployment, and therefore `execute` was undefined, and resolved to false (despite the documented default). This change moves `execute` switch from the global scope into `deploy` and to `bootstrap` and passes it into the `cliBootstrap` command, as well as respects the default in case the option passed to the deployment utility is `undefined`. It also emits a message to STDOUT in case `--no-execute` is provided to let user know that deployment hasn't really finished. Otherwise, it appears as if deployment is successful. The `deploy-no-execute` integration test was also "failing successfully" due to invalid usage of bash conditions, so this is also fixed here. Added integration test to verify that --no-execute is respected by `cdk bootstrap`.
…5-eks-patterns * '4955-eks-patterns' of github.com:arhea/aws-cdk: feat(cli): adding new option to `cdk deploy` to indicate whether ChangeSet should be executed (aws#4852) chore: move semantic.yaml to .github/ fix(core): unable to find stack by name using the cli in legacy mode (aws#4998) fix(ecs-patterns): Fix issue related to protocol being passed to target group (aws#4988) chore: Backport CHANGELOG entries from v1.16.2 (aws#4980) feat(custom-resources): python handler skelaton in readme (aws#4977) fix(logs): cannot use same Lambda for multiple SubscriptionFilters (aws#4975) release: v1.16.1 (aws#4965) chore: resolve inaccurate label line in depbot config (aws#4729) chore(deps): bump aws-sdk from 2.568.0 to 2.569.0 (aws#4958)
I created the option to NOT execute the ChangeSet via
cdk deploy
.The flag is called execute and by default is set to true. By not providing this flag, the workflow of
cdk deploy
will be the same.If anyone wants to NOT execute the ChangeSet, providing the flag
--no-execute
will pass the execution of the ChangeSet.You will be able to see the ChangeSet in AWS CloudFormation Console, validate the resources and discard or execute the ChangeSet.
closes #4739
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license