Amazon Web Services (AWS) - List CloudFormation Stack Resources using the AWS CLI

by
Jeremy Canfield |
Updated: June 21 2024
| Amazon Web Services (AWS) articles
This assumes you are familiar with CloudFormation. If not, check out my article FreeKB - Amazon Web Services (AWS) - Getting Started with CloudFormation.
The aws cloudformation list-stacks command can be used to list your CloudFormation stacks.
~]$ aws cloudformation list-stacks
{
"StackSummaries": [
{
"StackId": "arn:aws:cloudformation:us-east-1:123456789012:stack/foo/314b9ed0-2d14-11ef-a291-0e2664c75f79",
"StackName": "foo",
"CreationTime": "2024-06-18T01:52:00.225000+00:00",
"LastUpdatedTime": "2024-06-21T10:16:03.964000+00:00",
"StackStatus": "UPDATE_COMPLETE",
"DriftInformation": {
"StackDriftStatus": "NOT_CHECKED"
}
},
{
"StackId": "arn:aws:cloudformation:us-east-1:123456789012:stack/bar/77e1bd20-29ef-11ef-b8c9-0e33d6c7becd",
"StackName": "bar",
"CreationTime": "2024-06-14T01:46:30.856000+00:00",
"LastUpdatedTime": "2024-06-14T01:46:35.673000+00:00",
"StackStatus": "CREATE_COMPLETE",
"DriftInformation": {
"StackDriftStatus": "NOT_CHECKED"
}
}
]
}
A CloudFormation stack is a collection of resources. For example, one of the first CloudFormation Stacks I created was an Athena Postgres Connector which included 3 resources, an IAM Policy, an IAM Role, and a Lambda Function.
The aws cloudformation list-stack-resources command can be used to list the resources in a CloudFormation Stack.
~]$ aws cloudformation list-stack-resources --stack-name serverlessrepo-AthenaPostgreSQLConnector
{
"StackResourceSummaries": [
{
"LogicalResourceId": "FunctionExecutionPolicy",
"PhysicalResourceId": "serve-Funct-M6Jpg21O0Cjn",
"ResourceType": "AWS::IAM::Policy",
"LastUpdatedTimestamp": "2024-06-18T01:52:44.164000+00:00",
"ResourceStatus": "CREATE_COMPLETE",
"DriftInformation": {
"StackResourceDriftStatus": "NOT_CHECKED"
}
},
{
"LogicalResourceId": "FunctionRole",
"PhysicalResourceId": "serverlessrepo-AthenaPostgreSQLConnect-FunctionRole-gMFW3MYpoozw",
"ResourceType": "AWS::IAM::Role",
"LastUpdatedTimestamp": "2024-06-18T01:52:27.085000+00:00",
"ResourceStatus": "CREATE_COMPLETE",
"DriftInformation": {
"StackResourceDriftStatus": "NOT_CHECKED"
}
},
{
"LogicalResourceId": "JdbcConnectorConfig",
"PhysicalResourceId": "athenapostgres",
"ResourceType": "AWS::Lambda::Function",
"LastUpdatedTimestamp": "2024-06-21T10:16:14.544000+00:00",
"ResourceStatus": "UPDATE_COMPLETE",
"DriftInformation": {
"StackResourceDriftStatus": "NOT_CHECKED"
}
}
]
}
Did you find this article helpful?
If so, consider buying me a coffee over at