How to Group AWS Resources Based on Tags?

Use AWS Resource Groups to Logically Group AWS Resources

Published in
3 min readJun 14, 2023

--

We can logically group AWS resources using the AWS Resource Groups service. This article will demonstrate how we can logically group EC2 instances using their tags.

I have already deployed three EC2 instances, two of them are tagged as Env: Dev , and other one is tagged as Env: Test

  1. Let’s open Resource Groups and Tag Editor from AWS Console UI :
Resource Groups and Tag Editor

2. Then create a resource group:

3. Select Tag based group type:

4. Search for the resource types ( In this case, select AWS::EC2::Instance resource type )

5. Search for the Tags used on the EC2 instances → Add them → Press the Preview group resources button to view matched instances.

Preview of matched instances

6. Create the group with a name and description.

Create Group

Similarly, we can create several resource groups based on the tags

7. View all the groups:

Use case:

After creating resource groups, the next important step is determining their use. One practical application is to utilize them as targets when managing instances through AWS Systems Manager. For example, if we need to execute a shell command on 10 instances belonging to a resource group named DevGroup, the recommended approach would be to use AWS Systems Manager's "Run Command" feature with resource groups as targets.

Following is a sample demonstration:

  1. Search for a command document named AWS-RunShellScript

2. Write shell commands as per requirements.

3. Choose a resource group as the target.

4. Run the command and view the progress:

If you found this article helpful, please hit the Follow 👉 and Clap 👏 buttons to help me write more articles like this.
Thank You 🖤

🔔 Follow me on LinkedIn | GitHub | Twitter

--

--

Cloud Infrastructure Engineer | AWS Community Builder | AWS | Kubernetes | GitHub Actions | Terraform | 👇👉 linkedin.com/in/shamimice03 github.com/shamimice03