Use ListGroupResources with an AWS SDK or CLI - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use ListGroupResources with an AWS SDK or CLI

The following code examples show how to use ListGroupResources.

CLI
AWS CLI

To list all of the resources in a resource group

Example 1: The following list-resource-groups example lists all of the resources that are part of the specified resource group.

aws resource-groups list-group-resources \ --group-name tbq-WebServer

Output:

{ "ResourceIdentifiers": [ { "ResourceArn": "arn:aws:ec2:us-west-2:123456789012:instance/i-09f77fa38c12345ab", "ResourceType": "AWS::EC2::Instance" } ] }

Example 2: The following example lists all of the resources in the group that also have a 'resource-type' of the 'AWS::EC2::Instance'. :

aws resource-groups list-group-resources --group-name tbq-WebServer --filters Name=resource-type,Values=AWS::EC2::Instance

PowerShell
Tools for PowerShell

Example 1: This example lists group resources on the basis of filtered by resource type

Get-RGGroupResourceList -Filter @{Name="resource-type";Values="AWS::EC2::Instance"} -GroupName auto-yes | Select-Object -ExpandProperty ResourceIdentifiers

Output:

ResourceArn ResourceType ----------- ------------ arn:aws:ec2:eu-west-1:123456789012:instance/i-0123bc45b567890e1 AWS::EC2::Instance arn:aws:ec2:eu-west-1:123456789012:instance/i-0a1caf2345f67d8dc AWS::EC2::Instance arn:aws:ec2:eu-west-1:123456789012:instance/i-012e3cb4df567e8aa AWS::EC2::Instance arn:aws:ec2:eu-west-1:123456789012:instance/i-0fd12dd3456789012 AWS::EC2::Instance