Updating groups in Amazon Resource Groups - Amazon Resource Groups
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Updating groups in Amazon Resource Groups

To update a tag-based resource group in Resource Groups, you can edit the query and tags that are the basis of your group. You can add and remove resources from your group only by applying changes to the query or tags. You cannot select specific resources to add to or remove from your group. The best way to add or remove a specific resource from a group is to edit the resource's tags. Then verify that your resource group tag query either includes or omits the tag, depending on whether you want the resource in your group.

To update an Amazon CloudFormation stack-based resource group, you can choose a different stack. You can also add or remove resource types from the stack that you want to be part of the group. To change the resources that are available in the stack, update the Amazon CloudFormation template used to create the stack, and then update the stack in Amazon CloudFormation. For more information about how to update an Amazon CloudFormation stack, see Amazon CloudFormation stacks updates in the Amazon CloudFormation User Guide.

In the Amazon CLI, you update groups in two commands.

  • update-group, which you run to update a group's description.

  • update-group-query, which you run to update the resource query and tags that determine the group's member resources.

In the console, you cannot change an Amazon CloudFormation stack-based group to a tag-based query group, or vice versa. However, you can do this by using the Resource Groups API, including in the Amazon CLI.

Update tag-based query groups

Console

Update a tag-based group by changing the resource types or tags in the query on which the group is based. You can also add or change the group's description.

  1. Sign in to the Amazon Resource Groups console.

  2. In the navigation pane, under Saved Resource Groups, choose the name of the group, and then choose Edit.

    Note

    You can update only resource groups that you own. The Owner column shows account ownership for each resource group. Any groups with an account owner other than the one you're signed in to were created in Amazon License Manager. For more information, see Host resource groups in Amazon License Manager in the License Manager User Guide.

  3. On the Edit group page, under Grouping criteria, add or remove resource types. You can have a maximum of 20 resource types in a query. To remove a resource type, choose X on the resource type's label. Choose View group resources to see how the changes affect your group's resource members. In this walkthrough, we add the resource type AWS::RDS::DBInstance to the query.

  4. Still under Grouping criteria, edit the tags as needed. In this example, we filter for resources that have a tag key of Stage and add a tag value of Test. The tag value is optional, but narrows the results of the query further. To remove a tag, choose X on the tag's label.

  5. In Additional information, you can edit the group description. You cannot edit a group's name after the group has been created.

  6. (Optional) In Group tags, you can add or remove tags. Group tags are metadata about your resource group. They do not affect member resources. To change the resources that are returned by the resource group's query, edit the tags found under Grouping criteria.

    Group tags are useful if you plan to make this group a member of a larger group. Specifying at least a tag key is required to create a group. Therefore, be sure to add at least a tag key in Group tags to groups that you plan to nest into larger groups.

  7. Choose Preview group resources to retrieve the updated list of EC2 instances, S3 buckets, and Amazon RDS database instances in your account that match the specified tag keys. If you do not see resources in the list that you expect, be sure that the resources are tagged with tags that you specified inGrouping criteria.

  8. When you are finished, choose Save changes.

Amazon CLI & Amazon SDKs

In the Amazon CLI, you update a group's query and update a resource group's description by using two different commands. You cannot edit an existing group's name. In the Amazon CLI, you can change a tag-based group to a CloudFormation stack-based group, or vice versa.

  1. If you do not want to change the description of your group, skip this step and go on to the next. In an Amazon CLI session, type the following, and then press Enter, replacing the values for group name and description with your own.

    $ aws resource-groups update-group \ --group-name resource-group-name \ --description "description_text"

    The following command is an example.

    $ aws resource-groups update-group \ --group-name my-resource-group \ --description "EC2 instances, S3 buckets, and RDS DBs that we are using for the test stage."

    The command returns a full, updated description of the group.

  2. To update the query and tags of a group, type the following command. Replace the values for group name, resource types, tag keys, and tag values with your own. Then pres Enter. You can have a maximum of 20 resource types in a query.

    $ aws resource-groups update-group-query \ --group-name resource-group-name \ --resource-query '{"Type":"TAG_FILTERS_1_0","Query":"{\"ResourceTypeFilters\":[\"resource_type1\",\"resource_type2\"],\"TagFilters\":[{\"Key\":\"Key1\",\"Values\":[\"Value1\",\"Value2\"]},{\"Key\":\"Key2\",\"Values\":[\"Value1\",\"Value2\"]}]}"}'

    The following command is an example.

    $ 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\"]}]}"}'

    The command returns the updated query as a result.

Update an Amazon CloudFormation stack-based group

Console

You cannot change an Amazon CloudFormation stack-based group to a tag-based group in the Amazon Web Services Management Console. However, you can change the stack on which the group is based, or change the stack resource types that you want to include in the group. You can also add or change the group's description.

  1. Sign in to the Amazon Resource Groups console.

  2. In the navigation pane, under Saved resource groups, choose the name of the group, and then choose Edit.

  3. Note

    You can update only resource groups that you own. The Owner column shows account ownership for each resource group. Any groups with an account owner other than the one you're signed in to were created in Amazon License Manager. For more information, see Host resource groups in Amazon License Manager in the License Manager User Guide.

  4. On the Edit group page, under Grouping criteria, to change the stack on which your group is based, choose the stack from the drop-down list. A resource group can be based on only one stack. To filter the list of stacks, start typing the name of the stack. Only stacks with supported statuses appear in the list. For a list of supported statuses, see Creating query-based groups in Amazon Resource Groups in this guide.

  5. Add or remove resource types. Only resource types that are available in the stack are shown in the drop-down list. The default is All supported resource types. You can have a maximum of 20 resource types in a query. To remove a resource type, choose X on the resource type's label. For more information about which resource types are supported and can be in the group, see Resource types you can use with Amazon Resource Groups and Tag Editor.

  6. Choose Preview group resources to retrieve the list of resources in the Amazon CloudFormation stack that match your selected resource types.

  7. In Additional information, you can edit the group description. You cannot edit a group's name after the group has been created.

  8. In Group tags, add or remove tags. Group tags are metadata about your resource group. They do not affect member resources. To change the resources that are returned by the resource group's query, edit tags in Grouping criteria.

    Group tags are useful if you plan to make this group a member of a larger group. Specifying at least a tag key is required to create a group. Therefore, be sure to add at least a tag key in Group tags to groups that you plan to nest into larger groups.

  9. When you are finished, choose Save changes.

Amazon CLI & Amazon SDKs

In the Amazon CLI, you update a group's query and update a resource group's description by using two different commands. You cannot edit an existing group's name. In the Amazon CLI, you can change a tag-based group to a CloudFormation stack-based group, or vice versa.

  1. If you do not want to change the description of your group, skip this step and go on to the next. Run the following command, replacing the values for group name and description with your own.

    $ aws resource-groups update-group \ --group-name "resource-group-name" \ --description "description_text"

    The following command is an example.

    $ aws resource-groups update-group \ --group-name "My-CFN-stack-group" \ --description "EC2 instances, S3 buckets, and RDS DBs that we are using for the test stage."

    The command returns a full, updated description of the group.

  2. To update the query and tags of a group, run the following command. Replace the values for group name, stack identifier, and resource types with your own. To add resource types, provide the full list of resource types in the command, not only resource types you are adding. You can have a maximum of 20 resource types in a query.

    The stack_identifier is the stack ARN, as shown in the example command.

    $ aws resource-groups update-group-query \ --group-name resource-group-name \ --description "description" \ --resource-query '{"Type":"CLOUDFORMATION_STACK_1_0","Query":"{\"StackIdentifier\":\"stack_identifier\",\"ResourceTypeFilters\":[\"resource_type1\",\"resource_type2\"]}"}'

    The following command is an example.

    $ aws resource-groups update-group-query \ --group-name "my-resource-group" \ --description "Updated CloudFormation stack-based group" \ --resource-query '{"Type":"CLOUDFORMATION_STACK_1_0","Query":"{\"StackIdentifier\":\"arn:aws:cloudformation:us-west-2:810000000000:stack\/AWStestuseraccount\/fb0d5000-aba8-00e8-aa9e-50d5cEXAMPLE\",\"ResourceTypeFilters\":[\"AWS::EC2::Instance\",\"AWS::S3::Bucket\"]}"}'

    The command returns the updated query as a result.