Skip to content

Instantly share code, notes, and snippets.

@medwig
Last active November 27, 2018 21:13
Show Gist options
  • Select an option

  • Save medwig/4ecbfe8c14bd0c9fb7fef984d865690b to your computer and use it in GitHub Desktop.

Select an option

Save medwig/4ecbfe8c14bd0c9fb7fef984d865690b to your computer and use it in GitHub Desktop.
List cloudformation outputs of Serverless Framework deployment
sls_stack () {
if [ -z "$1" ];
then
output=$(sls info | grep -oP 'stack: \K.*$')
else
output=$(sls info -s $1 | grep -oP 'stack: \K.*$')
fi
if [ ! -z "$output" ];
then
echo $output
return 0
else
>&2 echo "ERROR: Could not find stack for stage=$1. Are you in an SLS repo? Does that stage exist?"
return 1
fi
}
sls_output () {
stack=$(sls_stack $1)
if [ $? -ne 0 ]; then
return $?
fi
echo stack: $stack
output=$(aws cloudformation describe-stacks --stack-name $stack --query 'Stacks[0].Outputs[]')
echo $output
}
alias sls-stack="sls_stack"
alias sls-output="sls_output"
@medwig
Copy link
Author

medwig commented Nov 27, 2018

Call from the terminal using:
$ sls-output dev
$ sls-output staging
$ sls-output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment