Skip to content

Instantly share code, notes, and snippets.

@atheiman
Created September 2, 2020 10:54
Show Gist options
  • Save atheiman/657c21c11adf53b271c5a392b6b1ebe1 to your computer and use it in GitHub Desktop.
Save atheiman/657c21c11adf53b271c5a392b6b1ebe1 to your computer and use it in GitHub Desktop.
Get CloudFormation export shell function
# 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