There are more AWS SDK examples available in the AWS Doc SDK Examples
Use DescribeStacks with an AWS SDK or CLI
The following code examples show how to use DescribeStacks.
Action examples are code excerpts from larger programs and must be run in context. You can see this action in context in the following code examples:
- CLI
-
- AWS CLI
-
To describe AWS CloudFormation stacks
The following
describe-stackscommand shows summary information for themyteststackstack:aws cloudformation describe-stacks --stack-namemyteststackOutput:
{ "Stacks": [ { "StackId": "arn:aws:cloudformation:us-east-1:123456789012:stack/myteststack/466df9e0-0dff-08e3-8e2f-5088487c4896", "Description": "AWS CloudFormation Sample Template S3_Bucket: Sample template showing how to create a publicly accessible S3 bucket. **WARNING** This template creates an S3 bucket. You will be billed for the AWS resources used if you create a stack from this template.", "Tags": [], "Outputs": [ { "Description": "Name of S3 bucket to hold website content", "OutputKey": "BucketName", "OutputValue": "myteststack-s3bucket-jssofi1zie2w" } ], "StackStatusReason": null, "CreationTime": "2013-08-23T01:02:15.422Z", "Capabilities": [], "StackName": "myteststack", "StackStatus": "CREATE_COMPLETE", "DisableRollback": false } ] }For more information, see Stacks in the AWS CloudFormation User Guide.
-
For API details, see DescribeStacks
in AWS CLI Command Reference.
-
- Go
-
- SDK for Go V2
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. import ( "context" "log" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/cloudformation" ) // StackOutputs defines a map of outputs from a specific stack. type StackOutputs map[string]string type CloudFormationActions struct { CfnClient *cloudformation.Client } // GetOutputs gets the outputs from a CloudFormation stack and puts them into a structured format. func (actor CloudFormationActions) GetOutputs(ctx context.Context, stackName string) StackOutputs { output, err := actor.CfnClient.DescribeStacks(ctx, &cloudformation.DescribeStacksInput{ StackName: aws.String(stackName), }) if err != nil || len(output.Stacks) == 0 { log.Panicf("Couldn't find a CloudFormation stack named %v. Here's why: %v\n", stackName, err) } stackOutputs := StackOutputs{} for _, out := range output.Stacks[0].Outputs { stackOutputs[*out.OutputKey] = *out.OutputValue } return stackOutputs }-
For API details, see DescribeStacks
in AWS SDK for Go API Reference.
-
- PowerShell
-
- Tools for PowerShell V4
-
Example 1: Returns a collection of Stack instances describing all of the user's stacks.
Get-CFNStackExample 2: Returns a Stack instance describing the specified stack
Get-CFNStack -StackName "myStack"-
For API details, see DescribeStacks in AWS Tools for PowerShell Cmdlet Reference (V4).
-
- Tools for PowerShell V5
-
Example 1: Returns a collection of Stack instances describing all of the user's stacks.
Get-CFNStackExample 2: Returns a Stack instance describing the specified stack
Get-CFNStack -StackName "myStack"-
For API details, see DescribeStacks in AWS Tools for PowerShell Cmdlet Reference (V5).
-