AWS Resource Groups

2020/12/23 - AWS Resource Groups - 1 new3 updated api methods

Changes  Update resource-groups client to latest version

PutGroupConfiguration (new) Link ¶

Attaches a service configuration to the specified group. This occurs asynchronously, and can take time to complete. You can use GetGroupConfiguration to check the status of the update.

Minimum permissions

To run this command, you must have the following permissions:

  • resource-groups:PutGroupConfiguration

See also: AWS API Documentation

Request Syntax

client.put_group_configuration(
    Group='string',
    Configuration=[
        {
            'Type': 'string',
            'Parameters': [
                {
                    'Name': 'string',
                    'Values': [
                        'string',
                    ]
                },
            ]
        },
    ]
)
type Group:

string

param Group:

The name or ARN of the resource group with the configuration that you want to update.

type Configuration:

list

param Configuration:

The new configuration to associate with the specified group. A configuration associates the resource group with an AWS service and specifies how the service can interact with the resources in the group. A configuration is an array of GroupConfigurationItem elements.

For information about the syntax of a service configuration, see Service configurations for resource groups.

rtype:

dict

returns:

Response Syntax

{}

Response Structure

  • (dict) --

GroupResources (updated) Link ¶
Changes (response)
{'Pending': [{'ResourceArn': 'string'}]}

Adds the specified resources to the specified group.

Minimum permissions

To run this command, you must have the following permissions:

  • resource-groups:GroupResources

See also: AWS API Documentation

Request Syntax

client.group_resources(
    Group='string',
    ResourceArns=[
        'string',
    ]
)
type Group:

string

param Group:

[REQUIRED]

The name or the ARN of the resource group to add resources to.

type ResourceArns:

list

param ResourceArns:

[REQUIRED]

The list of ARNs for resources to be added to the group.

  • (string) --

rtype:

dict

returns:

Response Syntax

{
    'Succeeded': [
        'string',
    ],
    'Failed': [
        {
            'ResourceArn': 'string',
            'ErrorMessage': 'string',
            'ErrorCode': 'string'
        },
    ],
    'Pending': [
        {
            'ResourceArn': 'string'
        },
    ]
}

Response Structure

  • (dict) --

    • Succeeded (list) --

      A list of ARNs of resources that were successfully added to the group by this operation.

      • (string) --

    • Failed (list) --

      A list of ARNs of any resources that failed to be added to the group by this operation.

      • (dict) --

        A resource that failed to be added to or removed from a group.

        • ResourceArn (string) --

          The ARN of the resource that failed to be added or removed.

        • ErrorMessage (string) --

          The error message text associated with the failure.

        • ErrorCode (string) --

          The error code associated with the failure.

    • Pending (list) --

      A list of ARNs of any resources that are still in the process of being added to the group by this operation. These pending additions continue asynchronously. You can check the status of pending additions by using the ListGroupResources operation, and checking the Resources array in the response and the Status field of each object in that array.

      • (dict) --

        A structure that identifies a resource that is currently pending addition to the group as a member. Adding a resource to a resource group happens asynchronously as a background task and this one isn't completed yet.

        • ResourceArn (string) --

          The Amazon resource name (ARN) of the resource that's in a pending state.

ListGroupResources (updated) Link ¶
Changes (response)
{'Resources': [{'Identifier': {'ResourceArn': 'string',
                               'ResourceType': 'string'},
                'Status': {'Name': 'PENDING'}}]}

Returns a list of ARNs of the resources that are members of a specified resource group.

Minimum permissions

To run this command, you must have the following permissions:

  • resource-groups:ListGroupResources

See also: AWS API Documentation

Request Syntax

client.list_group_resources(
    GroupName='string',
    Group='string',
    Filters=[
        {
            'Name': 'resource-type',
            'Values': [
                'string',
            ]
        },
    ],
    MaxResults=123,
    NextToken='string'
)
type GroupName:

string

param GroupName:
type Group:

string

param Group:

The name or the ARN of the resource group

type Filters:

list

param Filters:

Filters, formatted as ResourceFilter objects, that you want to apply to a ListGroupResources operation. Filters the results to include only those of the specified resource types.

  • resource-type - Filter resources by their type. Specify up to five resource types in the format AWS::ServiceCode::ResourceType. For example, AWS::EC2::Instance, or AWS::S3::Bucket.

When you specify a resource-type filter for ListGroupResources, AWS Resource Groups validates your filter resource types against the types that are defined in the query associated with the group. For example, if a group contains only S3 buckets because its query specifies only that resource type, but your resource-type filter includes EC2 instances, AWS Resource Groups does not filter for EC2 instances. In this case, a ListGroupResources request returns a BadRequestException error with a message similar to the following:

The resource types specified as filters in the request are not valid.

The error includes a list of resource types that failed the validation because they are not part of the query associated with the group. This validation doesn't occur when the group query specifies AWS::AllSupported, because a group based on such a query can contain any of the allowed resource types for the query type (tag-based or AWS CloudFormation stack-based queries).

  • (dict) --

    A filter name and value pair that is used to obtain more specific results from a list of resources.

    • Name (string) -- [REQUIRED]

      The name of the filter. Filter names are case-sensitive.

    • Values (list) -- [REQUIRED]

      One or more filter values. Allowed filter values vary by resource filter name, and are case-sensitive.

      • (string) --

type MaxResults:

integer

param MaxResults:

The total number of results that you want included on each page of the response. If you do not include this parameter, it defaults to a value that is specific to the operation. If additional items exist beyond the maximum you specify, the NextToken response element is present and has a value (is not null). Include that value as the NextToken request parameter in the next call to the operation to get the next part of the results. Note that the service might return fewer results than the maximum even when there are more results available. You should check NextToken after every operation to ensure that you receive all of the results.

type NextToken:

string

param NextToken:

The parameter for receiving additional results if you receive a NextToken response in a previous request. A NextToken response indicates that more output is available. Set this parameter to the value provided by a previous call's NextToken response to indicate where the output should continue from.

rtype:

dict

returns:

Response Syntax

{
    'Resources': [
        {
            'Identifier': {
                'ResourceArn': 'string',
                'ResourceType': 'string'
            },
            'Status': {
                'Name': 'PENDING'
            }
        },
    ],
    'ResourceIdentifiers': [
        {
            'ResourceArn': 'string',
            'ResourceType': 'string'
        },
    ],
    'NextToken': 'string',
    'QueryErrors': [
        {
            'ErrorCode': 'CLOUDFORMATION_STACK_INACTIVE'|'CLOUDFORMATION_STACK_NOT_EXISTING',
            'Message': 'string'
        },
    ]
}

Response Structure

  • (dict) --

    • Resources (list) --

      An array of resources from which you can determine each resource's identity, type, and group membership status.

      • (dict) --

        A structure returned by the ListGroupResources operation that contains identity and group membership status information for one of the resources in the group.

        • Identifier (dict) --

          A structure that contains the ARN of a resource and its resource type.

          • ResourceArn (string) --

            The ARN of a resource.

          • ResourceType (string) --

            The resource type of a resource, such as AWS::EC2::Instance.

        • Status (dict) --

          A structure that contains the status of this resource's membership in the group.

          • Name (string) --

            The current status.

    • ResourceIdentifiers (list) --

      • (dict) --

        A structure that contains the ARN of a resource and its resource type.

        • ResourceArn (string) --

          The ARN of a resource.

        • ResourceType (string) --

          The resource type of a resource, such as AWS::EC2::Instance.

    • NextToken (string) --

      If present, indicates that more output is available than is included in the current response. Use this value in the NextToken request parameter in a subsequent call to the operation to get the next part of the output. You should repeat this until the NextToken response element comes back as null.

    • QueryErrors (list) --

      A list of QueryError objects. Each error is an object that contains ErrorCode and Message structures. Possible values for ErrorCode are CLOUDFORMATION_STACK_INACTIVE and CLOUDFORMATION_STACK_NOT_EXISTING.

      • (dict) --

        A two-part error structure that can occur in ListGroupResources or SearchResources operations on CloudFormation stack-based queries. The error occurs if the CloudFormation stack on which the query is based either does not exist, or has a status that renders the stack inactive. A QueryError occurrence does not necessarily mean that AWS Resource Groups could not complete the operation, but the resulting group might have no member resources.

        • ErrorCode (string) --

          Possible values are CLOUDFORMATION_STACK_INACTIVE and CLOUDFORMATION_STACK_NOT_EXISTING.

        • Message (string) --

          A message that explains the ErrorCode value. Messages might state that the specified CloudFormation stack does not exist (or no longer exists). For CLOUDFORMATION_STACK_INACTIVE, the message typically states that the CloudFormation stack has a status that is not (or no longer) active, such as CREATE_FAILED.

UngroupResources (updated) Link ¶
Changes (response)
{'Pending': [{'ResourceArn': 'string'}]}

Removes the specified resources from the specified group.

Minimum permissions

To run this command, you must have the following permissions:

  • resource-groups:UngroupResources

See also: AWS API Documentation

Request Syntax

client.ungroup_resources(
    Group='string',
    ResourceArns=[
        'string',
    ]
)
type Group:

string

param Group:

[REQUIRED]

The name or the ARN of the resource group from which to remove the resources.

type ResourceArns:

list

param ResourceArns:

[REQUIRED]

The ARNs of the resources to be removed from the group.

  • (string) --

rtype:

dict

returns:

Response Syntax

{
    'Succeeded': [
        'string',
    ],
    'Failed': [
        {
            'ResourceArn': 'string',
            'ErrorMessage': 'string',
            'ErrorCode': 'string'
        },
    ],
    'Pending': [
        {
            'ResourceArn': 'string'
        },
    ]
}

Response Structure

  • (dict) --

    • Succeeded (list) --

      A list of resources that were successfully removed from the group by this operation.

      • (string) --

    • Failed (list) --

      A list of any resources that failed to be removed from the group by this operation.

      • (dict) --

        A resource that failed to be added to or removed from a group.

        • ResourceArn (string) --

          The ARN of the resource that failed to be added or removed.

        • ErrorMessage (string) --

          The error message text associated with the failure.

        • ErrorCode (string) --

          The error code associated with the failure.

    • Pending (list) --

      A list of any resources that are still in the process of being removed from the group by this operation. These pending removals continue asynchronously. You can check the status of pending removals by using the ListGroupResources operation. After the resource is successfully removed, it no longer appears in the response.

      • (dict) --

        A structure that identifies a resource that is currently pending addition to the group as a member. Adding a resource to a resource group happens asynchronously as a background task and this one isn't completed yet.

        • ResourceArn (string) --

          The Amazon resource name (ARN) of the resource that's in a pending state.