Created
September 2, 2020 10:54
-
-
Save atheiman/657c21c11adf53b271c5a392b6b1ebe1 to your computer and use it in GitHub Desktop.
Get CloudFormation export shell function
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
# Example usage: | |
# | |
# $ getCfnExport MyStack-RoleArn | |
# arn:aws:iam:us-east-1:111111111111:TheExportedRole | |
# | |
function getCfnExport { | |
local EXPORT_VALUE="$(aws cloudformation list-exports --output text --query "Exports[?Name=='${1?}'].Value")" | |
if [ -z "$EXPORT_VALUE" ]; then | |
echo "Could not find CloudFormation export '${1}'" 1>&2 | |
# Use for CI/CD pipeline | |
#exit 1 | |
# Use for normal shell | |
return 1 | |
else | |
echo ${EXPORT_VALUE} | |
return 0 | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment