Explore Courses Blog Tutorials Interview Questions
0 votes
in AWS by (12.9k points)

I am using the below to get the stack information I want via AWS Cli:

aws cloudformation --region ap-southeast-2 describe-stacks --stack-name mystack

It's returning result OK:


    "Stacks": [


            "StackId": "arn:aws:mystackid", 

            "LastUpdatedTime": "2017-01-13T04:59:17.472Z", 

            "Tags": [], 

            "Outputs": [


                    "OutputKey": "Ec2Sg", 

                    "OutputValue": "sg-97e13dff"



                    "OutputKey": "DbUrl", 

                    "OutputValue": "myUrl"



            "CreationTime": "2017-01-13T03:27:18.893Z", 

            "StackName": "mystack", 

            "NotificationARNs": [], 

            "StackStatus": "UPDATE_ROLLBACK_COMPLETE", 

            "DisableRollback": false




But I do not know how to return only the value of OutputValue which is myUrl

As I do not need the rest, just myUrl.

Is that possible via aws cloudformation describe-stacks?

1 Answer

0 votes
by (18.2k points)

You can use the --query command as shown below:

--query "Stacks[0].Outputs[1].OutputValue"

Note: If your number of output changes, you might get an unexpected result using the above command. Using DbURL will help in that case.

Try the following command

--query "Stacks[0].Outputs[?OutputKey=='DbUrl'].OutputValue" --output text

Related questions

0 votes
1 answer

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer

Browse Categories