-
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
Changes from all commits
d275539
e2a7003
d8fc781
acd543e
0d8ab27
3e9ebdc
cfc0486
f31d1cd
bd9caa9
6399716
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ export interface DeployStackOptions { | |
ci?: boolean; | ||
reuseAssets?: string[]; | ||
tags?: Tag[]; | ||
execute?: boolean; | ||
} | ||
|
||
const LARGE_TEMPLATE_SIZE_KB = 50; | ||
|
@@ -92,14 +93,21 @@ export async function deployStack(options: DeployStackOptions): Promise<DeploySt | |
return { noOp: true, outputs: await getStackOutputs(cfn, deployName), stackArn: changeSet.StackId! }; | ||
} | ||
|
||
debug('Initiating execution of changeset %s on stack %s', changeSetName, deployName); | ||
await cfn.executeChangeSet({ StackName: deployName, ChangeSetName: changeSetName }).promise(); | ||
// tslint:disable-next-line:max-line-length | ||
const monitor = options.quiet ? undefined : new StackActivityMonitor(cfn, deployName, options.stack, (changeSetDescription.Changes || []).length).start(); | ||
debug('Execution of changeset %s on stack %s has started; waiting for the update to complete...', changeSetName, deployName); | ||
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 commentThe 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 |
||
debug('Initiating execution of changeset %s on stack %s', changeSetName, deployName); | ||
await cfn.executeChangeSet({StackName: deployName, ChangeSetName: changeSetName}).promise(); | ||
// tslint:disable-next-line:max-line-length | ||
const monitor = options.quiet ? undefined : new StackActivityMonitor(cfn, deployName, options.stack, (changeSetDescription.Changes || []).length).start(); | ||
debug('Execution of changeset %s on stack %s has started; waiting for the update to complete...', changeSetName, deployName); | ||
await waitForStack(cfn, deployName); | ||
if (monitor) { | ||
await monitor.stop(); | ||
} | ||
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 commentThe 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. |
||
cfn.executeChangeSet(); | ||
shivlaks marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we calling |
||
} | ||
return { noOp: false, outputs: await getStackOutputs(cfn, deployName), stackArn: changeSet.StackId! }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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. |
||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
scriptdir=$(cd $(dirname $0) && pwd) | ||
source ${scriptdir}/common.bash | ||
# ---------------------------------------------------------- | ||
|
||
setup | ||
|
||
stack_arn=$(cdk deploy -v ${STACK_NAME_PREFIX}-test-2 --no-execute) | ||
echo "Stack deployed successfully" | ||
|
||
# verify that we only deployed a single stack (there's a single ARN in the output) | ||
assert_lines "${stack_arn}" 1 | ||
|
||
# verify the number of resources in the stack | ||
response_json=$(mktemp).json | ||
aws cloudformation describe-stacks --stack-name ${stack_arn} > ${response_json} | ||
|
||
stack_status=$(node -e "console.log(require('${response_json}').Stacks[0].StackStatus)") | ||
if [ "${stack_status}" -ne "REVIEW_IN_PROGRESS" ]; then | ||
fail "Expected stack to be in status REVIEW_IN_PROGRESS but got ${stack_status}" | ||
fi | ||
|
||
# destroy | ||
cdk destroy -f ${STACK_NAME_PREFIX}-test-2 | ||
|
||
echo "✅ success" |
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?