There are more AWS SDK examples available in the AWS Doc SDK Examples
Use ListStacks
with an AWS SDK or CLI
The following code examples show how to use ListStacks
.
- CLI
-
- AWS CLI
-
To list AWS CloudFormation stacks
The following
list-stacks
command shows a summary of all stacks that have a status ofCREATE_COMPLETE
:aws cloudformation list-stacks --stack-status-filter
CREATE_COMPLETE
Output:
[ { "StackId": "arn:aws:cloudformation:us-east-1:123456789012:stack/myteststack/466df9e0-0dff-08e3-8e2f-5088487c4896", "TemplateDescription": "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.", "StackStatusReason": null, "CreationTime": "2013-08-26T03:27:10.190Z", "StackName": "myteststack", "StackStatus": "CREATE_COMPLETE" } ]
-
For API details, see ListStacks
in AWS CLI Command Reference.
-
- PowerShell
-
- Tools for PowerShell
-
Example 1: Returns summary information for all stacks.
Get-CFNStackSummary
Example 2: Returns summary information for all stacks that are currently being created.
Get-CFNStackSummary -StackStatusFilter "CREATE_IN_PROGRESS"
Example 3: Returns summary information for all stacks that are currently being created or updated.
Get-CFNStackSummary -StackStatusFilter @("CREATE_IN_PROGRESS", "UPDATE_IN_PROGRESS")
Example 4: Returns summary information for all stacks that are currently being created or updated using manual paging of the results. The starting token for the next page is retrieved after every call with $null indicating no more details remain to be retrieved.
$nextToken = $null do { Get-CFNStackSummary -StackStatusFilter @("CREATE_IN_PROGRESS", "UPDATE_IN_PROGRESS") -NextToken $nextToken $nextToken = $AWSHistory.LastServiceResponse.NextToken } while ($nextToken -ne $null)
-
For API details, see ListStacks in AWS Tools for PowerShell Cmdlet Reference.
-