-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): write stack outputs to a file (#7020)
feat(cli): write stack outputs to a file Write stack outputs from deployments into a file. A flag `--outputs-file` can be provided where stack outputs will be written in `json` format. Supports multi-stack and wild-card deployments where all the generated outputs from deployed stacks will be written to the outputs file. Closes #1773
- Loading branch information
Showing
10 changed files
with
187 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
packages/aws-cdk/test/integ/cli/cdk-deploy-wildcard-with-outputs-expected.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"cdk-toolkit-integration-outputs-test-1": { | ||
"TopicName": "MyTopic" | ||
}, | ||
"cdk-toolkit-integration-outputs-test-2": { | ||
"TopicName": "MyOtherTopic" | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/aws-cdk/test/integ/cli/cdk-deploy-with-outputs-expected.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"cdk-toolkit-integration-outputs-test-1": { | ||
"TopicName": "MyTopic" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
packages/aws-cdk/test/integ/cli/test-cdk-deploy-wildcard-with-outputs.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
scriptdir=$(cd $(dirname $0) && pwd) | ||
source ${scriptdir}/common.bash | ||
# ---------------------------------------------------------- | ||
|
||
setup | ||
|
||
outputs_file=${integ_test_dir}/outputs/outputs.json | ||
expected_outputs=${scriptdir}/cdk-deploy-wildcard-with-outputs-expected.json | ||
|
||
# deploy all outputs stacks | ||
cdk deploy ${STACK_NAME_PREFIX}-outputs-test-\* --outputs-file ${outputs_file} | ||
echo "Stacks deployed successfully" | ||
|
||
# verify generated outputs file | ||
generated_outputs_file="$(cat ${outputs_file})" | ||
expected_outputs_file="$(cat ${expected_outputs})" | ||
if [[ "${generated_outputs_file}" != "${expected_outputs_file}" ]]; then | ||
fail "unexpected outputs. Expected: ${expected_outputs_file} Actual: ${generated_outputs_file}" | ||
fi | ||
|
||
# destroy | ||
rm ${outputs_file} | ||
cdk destroy -f ${STACK_NAME_PREFIX}-outputs-test-1 | ||
cdk destroy -f ${STACK_NAME_PREFIX}-outputs-test-2 | ||
|
||
echo "✅ success" |
26 changes: 26 additions & 0 deletions
26
packages/aws-cdk/test/integ/cli/test-cdk-deploy-with-outputs.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
scriptdir=$(cd $(dirname $0) && pwd) | ||
source ${scriptdir}/common.bash | ||
# ---------------------------------------------------------- | ||
|
||
setup | ||
|
||
outputs_file=${integ_test_dir}/outputs/outputs.json | ||
expected_outputs=${scriptdir}/cdk-deploy-with-outputs-expected.json | ||
|
||
cdk deploy -v ${STACK_NAME_PREFIX}-outputs-test-1 --outputs-file ${outputs_file} | ||
echo "Stack deployed successfully" | ||
|
||
# verify generated outputs file | ||
generated_outputs_file="$(cat ${outputs_file})" | ||
expected_outputs_file="$(cat ${expected_outputs})" | ||
if [[ "${generated_outputs_file}" != "${expected_outputs_file}" ]]; then | ||
fail "unexpected outputs. Expected: ${expected_outputs_file} Actual: ${generated_outputs_file}" | ||
fi | ||
|
||
# destroy | ||
rm ${outputs_file} | ||
cdk destroy -f ${STACK_NAME_PREFIX}-outputs-test-1 | ||
|
||
echo "✅ success" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters