# Resource Groups

Source: /aws/services/resource-groups/

## Introduction

Resource Groups allow developers to organize and manage their AWS resources more efficiently.
Resource Groups allow for a unified view of their resources allowing developers to perform specific actions, such as resource tagging, access control, and policy enforcement across multiple resources simultaneously.
Resource Groups in AWS provide two types of queries that developers can use to build groups: Tag-based queries and CloudFormation stack-based queries.
With Tag-based queries, developers can organize resources based on common attributes or characteristics, while CloudFormation stack-based queries allow developers to group resources that are deployed together as part of a CloudFormation stack.

LocalStack allows you to use the Resource Groups APIs in your local environment to group and categorize resources based on criteria such as tags, resource types, regions, or custom attributes.
The supported APIs are available on our [API Coverage section](#api-coverage), which provides information on the extent of Resource Group's integration with LocalStack.
For tag-centric operations across AWS resources, see the [Resource Groups Tagging API](/aws/services/resource-groups-tagging-api/) guide.

## Getting Started

This guide is designed for users new to Resource Groups and assumes basic knowledge of the AWS CLI and our [`lstk aws`](/aws/developer-tools/running-localstack/lstk/cloud-and-iac-commands/#aws) command.

Start your LocalStack container using your preferred method.
We will demonstrate how to create a Resource Group using the AWS CLI.
We will use tag-based query to create a resource group.
However, you can also use CloudFormation stack-based queries to create a resource group.

### Create a Resource Group

Resource Groups in AWS are built around the concept of queries, which serve as a fundamental component.
The tag-based queries list the resource types in the format `AWS::<service>::<resource>` (e.g. `AWS::Lambda::Function` along with specified tags.
A tag-based group is created based on a query of type `TAG_FILTERS_1_0`.

Use the [`CreateGroup`](https://docs.aws.amazon.com/resource-groups/latest/APIReference/API_CreateGroup.html) API to create a Resource Group.
Run the following command to create a Resource Group named `my-resource-group`:

```bash
lstk aws resource-groups create-group \
    --name my-resource-group \
    --resource-query '{"Type":"TAG_FILTERS_1_0","Query":"{\"ResourceTypeFilters\":[\"AWS::EC2::Instance\"],\"TagFilters\":[{\"Key\":\"Stage\",\"Values\":[\"Test\"]}]}"}'
```

You can also specify `AWS::AllSupported` as the `ResourceTypeFilters` value to include all supported resource types in the group.

### Update a Resource Group

To update a Resource Group, use the [`UpdateGroup`](https://docs.aws.amazon.com/resource-groups/latest/APIReference/API_UpdateGroup.html) API.
Execute the following command to update the Resource Group `my-resource-group`:

```bash
lstk aws resource-groups update-group \
    --group-name my-resource-group \
    --description "EC2 S3 buckets and RDS DBs that we are using for the test stage"
```

Furthermore, you can also update the query and tags associated with a Resource Group using the [`UpdateGroup`](https://docs.aws.amazon.com/resource-groups/latest/APIReference/API_UpdateGroup.html) API.
Run the following command to update the query and tags of the Resource Group `my-resource-group`:

```bash
lstk aws resource-groups update-group-query \
    --group-name my-resource-group \
    --resource-query '{"Type":"TAG_FILTERS_1_0","Query":"{\"ResourceTypeFilters\":[\"AWS::EC2::Instance\",\"AWS::S3::Bucket\",\"AWS::RDS::DBInstance\"],\"TagFilters\":[{\"Key\":\"Stage\",\"Values\":[\"Test\"]}]}"}'
```

### Delete a Resource Group

To delete a Resource Group, use the [`DeleteGroup`](https://docs.aws.amazon.com/resource-groups/latest/APIReference/API_DeleteGroup.html) API.
Run the following command to delete the Resource Group `my-resource-group`:

```bash
lstk aws resource-groups delete-group \
    --group-name my-resource-group
```

## API Coverage


### Resource Groups API coverage

Source service: `resource-groups`. 16 of 23 tracked operations are implemented.

Service documentation: /aws/services/resource-groups/
License availability: available starting with the Hobby plan. See /aws/licensing/ for current plan details.

| Operation | Status |
| --- | --- |
| CancelTagSyncTask | Implemented |
| CreateGroup | Implemented |
| DeleteGroup | Implemented |
| GetAccountSettings | Not implemented |
| GetGroup | Implemented |
| GetGroupConfiguration | Implemented |
| GetGroupQuery | Implemented |
| GetTagSyncTask | Implemented |
| GetTags | Implemented |
| GroupResources | Not implemented |
| ListGroupResources | Not implemented |
| ListGroupingStatuses | Not implemented |
| ListGroups | Implemented |
| ListTagSyncTasks | Implemented |
| PutGroupConfiguration | Implemented |
| SearchResources | Not implemented |
| StartTagSyncTask | Implemented |
| Tag | Implemented |
| UngroupResources | Not implemented |
| Untag | Implemented |
| UpdateAccountSettings | Not implemented |
| UpdateGroup | Implemented |
| UpdateGroupQuery | Implemented |
