Last active
November 27, 2018 21:13
-
-
Save medwig/4ecbfe8c14bd0c9fb7fef984d865690b to your computer and use it in GitHub Desktop.
List cloudformation outputs of Serverless Framework deployment
This file contains hidden or 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
| 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" |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Call from the terminal using:
$ sls-output dev$ sls-output staging$ sls-output