Amazon Recycle Bin

2022/02/03 - Amazon Recycle Bin - 4 updated api methods

Changes  Add EC2 Image recycle bin support.

CreateRule (updated) Link ¶
Changes (both)
{'ResourceType': {'EC2_IMAGE'}}

Creates a Recycle Bin retention rule. For more information, see Create Recycle Bin retention rules in the Amazon Elastic Compute Cloud User Guide.

See also: AWS API Documentation

Request Syntax

client.create_rule(
    RetentionPeriod={
        'RetentionPeriodValue': 123,
        'RetentionPeriodUnit': 'DAYS'
    },
    Description='string',
    Tags=[
        {
            'Key': 'string',
            'Value': 'string'
        },
    ],
    ResourceType='EBS_SNAPSHOT'|'EC2_IMAGE',
    ResourceTags=[
        {
            'ResourceTagKey': 'string',
            'ResourceTagValue': 'string'
        },
    ]
)
type RetentionPeriod:

dict

param RetentionPeriod:

[REQUIRED]

Information about the retention period for which the retention rule is to retain resources.

  • RetentionPeriodValue (integer) -- [REQUIRED]

    The period value for which the retention rule is to retain resources. The period is measured using the unit specified for RetentionPeriodUnit.

  • RetentionPeriodUnit (string) -- [REQUIRED]

    The unit of time in which the retention period is measured. Currently, only DAYS is supported.

type Description:

string

param Description:

The retention rule description.

type Tags:

list

param Tags:

Information about the tags to assign to the retention rule.

  • (dict) --

    Information about the tags to assign to the retention rule.

    • Key (string) -- [REQUIRED]

      The tag key.

    • Value (string) -- [REQUIRED]

      The tag value.

type ResourceType:

string

param ResourceType:

[REQUIRED]

The resource type to be retained by the retention rule. Currently, only Amazon EBS snapshots and EBS-backed AMIs are supported. To retain snapshots, specify EBS_SNAPSHOT. To retain EBS-backed AMIs, specify EC2_IMAGE.

type ResourceTags:

list

param ResourceTags:

Specifies the resource tags to use to identify resources that are to be retained by a tag-level retention rule. For tag-level retention rules, only deleted resources, of the specified resource type, that have one or more of the specified tag key and value pairs are retained. If a resource is deleted, but it does not have any of the specified tag key and value pairs, it is immediately deleted without being retained by the retention rule.

You can add the same tag key and value pair to a maximum or five retention rules.

To create a Region-level retention rule, omit this parameter. A Region-level retention rule does not have any resource tags specified. It retains all deleted resources of the specified resource type in the Region in which the rule is created, even if the resources are not tagged.

  • (dict) --

    Information about the resource tags used to identify resources that are retained by the retention rule.

    • ResourceTagKey (string) -- [REQUIRED]

      The tag key.

    • ResourceTagValue (string) --

      The tag value.

rtype:

dict

returns:

Response Syntax

{
    'Identifier': 'string',
    'RetentionPeriod': {
        'RetentionPeriodValue': 123,
        'RetentionPeriodUnit': 'DAYS'
    },
    'Description': 'string',
    'Tags': [
        {
            'Key': 'string',
            'Value': 'string'
        },
    ],
    'ResourceType': 'EBS_SNAPSHOT'|'EC2_IMAGE',
    'ResourceTags': [
        {
            'ResourceTagKey': 'string',
            'ResourceTagValue': 'string'
        },
    ],
    'Status': 'pending'|'available'
}

Response Structure

  • (dict) --

    • Identifier (string) --

      The unique ID of the retention rule.

    • RetentionPeriod (dict) --

      Information about the retention period for which the retention rule is to retain resources.

      • RetentionPeriodValue (integer) --

        The period value for which the retention rule is to retain resources. The period is measured using the unit specified for RetentionPeriodUnit.

      • RetentionPeriodUnit (string) --

        The unit of time in which the retention period is measured. Currently, only DAYS is supported.

    • Description (string) --

      The retention rule description.

    • Tags (list) --

      Information about the tags assigned to the retention rule.

      • (dict) --

        Information about the tags to assign to the retention rule.

        • Key (string) --

          The tag key.

        • Value (string) --

          The tag value.

    • ResourceType (string) --

      The resource type retained by the retention rule.

    • ResourceTags (list) --

      Information about the resource tags used to identify resources that are retained by the retention rule.

      • (dict) --

        Information about the resource tags used to identify resources that are retained by the retention rule.

        • ResourceTagKey (string) --

          The tag key.

        • ResourceTagValue (string) --

          The tag value.

    • Status (string) --

      The state of the retention rule. Only retention rules that are in the available state retain resources.

GetRule (updated) Link ¶
Changes (response)
{'ResourceType': {'EC2_IMAGE'}}

Gets information about a Recycle Bin retention rule.

See also: AWS API Documentation

Request Syntax

client.get_rule(
    Identifier='string'
)
type Identifier:

string

param Identifier:

[REQUIRED]

The unique ID of the retention rule.

rtype:

dict

returns:

Response Syntax

{
    'Identifier': 'string',
    'Description': 'string',
    'ResourceType': 'EBS_SNAPSHOT'|'EC2_IMAGE',
    'RetentionPeriod': {
        'RetentionPeriodValue': 123,
        'RetentionPeriodUnit': 'DAYS'
    },
    'ResourceTags': [
        {
            'ResourceTagKey': 'string',
            'ResourceTagValue': 'string'
        },
    ],
    'Status': 'pending'|'available'
}

Response Structure

  • (dict) --

    • Identifier (string) --

      The unique ID of the retention rule.

    • Description (string) --

      The retention rule description.

    • ResourceType (string) --

      The resource type retained by the retention rule.

    • RetentionPeriod (dict) --

      Information about the retention period for which the retention rule is to retain resources.

      • RetentionPeriodValue (integer) --

        The period value for which the retention rule is to retain resources. The period is measured using the unit specified for RetentionPeriodUnit.

      • RetentionPeriodUnit (string) --

        The unit of time in which the retention period is measured. Currently, only DAYS is supported.

    • ResourceTags (list) --

      Information about the resource tags used to identify resources that are retained by the retention rule.

      • (dict) --

        Information about the resource tags used to identify resources that are retained by the retention rule.

        • ResourceTagKey (string) --

          The tag key.

        • ResourceTagValue (string) --

          The tag value.

    • Status (string) --

      The state of the retention rule. Only retention rules that are in the available state retain resources.

ListRules (updated) Link ¶
Changes (request)
{'ResourceType': {'EC2_IMAGE'}}

Lists the Recycle Bin retention rules in the Region.

See also: AWS API Documentation

Request Syntax

client.list_rules(
    MaxResults=123,
    NextToken='string',
    ResourceType='EBS_SNAPSHOT'|'EC2_IMAGE',
    ResourceTags=[
        {
            'ResourceTagKey': 'string',
            'ResourceTagValue': 'string'
        },
    ]
)
type MaxResults:

integer

param MaxResults:

The maximum number of results to return with a single call. To retrieve the remaining results, make another call with the returned NextToken value.

type NextToken:

string

param NextToken:

The token for the next page of results.

type ResourceType:

string

param ResourceType:

[REQUIRED]

The resource type retained by the retention rule. Only retention rules that retain the specified resource type are listed. Currently, only Amazon EBS snapshots and EBS-backed AMIs are supported. To list retention rules that retain snapshots, specify EBS_SNAPSHOT. To list retention rules that retain EBS-backed AMIs, specify EC2_IMAGE.

type ResourceTags:

list

param ResourceTags:

Information about the resource tags used to identify resources that are retained by the retention rule.

  • (dict) --

    Information about the resource tags used to identify resources that are retained by the retention rule.

    • ResourceTagKey (string) -- [REQUIRED]

      The tag key.

    • ResourceTagValue (string) --

      The tag value.

rtype:

dict

returns:

Response Syntax

{
    'Rules': [
        {
            'Identifier': 'string',
            'Description': 'string',
            'RetentionPeriod': {
                'RetentionPeriodValue': 123,
                'RetentionPeriodUnit': 'DAYS'
            }
        },
    ],
    'NextToken': 'string'
}

Response Structure

  • (dict) --

    • Rules (list) --

      Information about the retention rules.

      • (dict) --

        Information about a Recycle Bin retention rule.

        • Identifier (string) --

          The unique ID of the retention rule.

        • Description (string) --

          The retention rule description.

        • RetentionPeriod (dict) --

          Information about the retention period for which the retention rule is to retain resources.

          • RetentionPeriodValue (integer) --

            The period value for which the retention rule is to retain resources. The period is measured using the unit specified for RetentionPeriodUnit.

          • RetentionPeriodUnit (string) --

            The unit of time in which the retention period is measured. Currently, only DAYS is supported.

    • NextToken (string) --

      The token to use to retrieve the next page of results. This value is null when there are no more results to return.

UpdateRule (updated) Link ¶
Changes (both)
{'ResourceType': {'EC2_IMAGE'}}

Updates an existing Recycle Bin retention rule. For more information, see Update Recycle Bin retention rules in the Amazon Elastic Compute Cloud User Guide.

See also: AWS API Documentation

Request Syntax

client.update_rule(
    Identifier='string',
    RetentionPeriod={
        'RetentionPeriodValue': 123,
        'RetentionPeriodUnit': 'DAYS'
    },
    Description='string',
    ResourceType='EBS_SNAPSHOT'|'EC2_IMAGE',
    ResourceTags=[
        {
            'ResourceTagKey': 'string',
            'ResourceTagValue': 'string'
        },
    ]
)
type Identifier:

string

param Identifier:

[REQUIRED]

The unique ID of the retention rule.

type RetentionPeriod:

dict

param RetentionPeriod:

Information about the retention period for which the retention rule is to retain resources.

  • RetentionPeriodValue (integer) -- [REQUIRED]

    The period value for which the retention rule is to retain resources. The period is measured using the unit specified for RetentionPeriodUnit.

  • RetentionPeriodUnit (string) -- [REQUIRED]

    The unit of time in which the retention period is measured. Currently, only DAYS is supported.

type Description:

string

param Description:

The retention rule description.

type ResourceType:

string

param ResourceType:

The resource type to be retained by the retention rule. Currently, only Amazon EBS snapshots and EBS-backed AMIs are supported. To retain snapshots, specify EBS_SNAPSHOT. To retain EBS-backed AMIs, specify EC2_IMAGE.

type ResourceTags:

list

param ResourceTags:

Specifies the resource tags to use to identify resources that are to be retained by a tag-level retention rule. For tag-level retention rules, only deleted resources, of the specified resource type, that have one or more of the specified tag key and value pairs are retained. If a resource is deleted, but it does not have any of the specified tag key and value pairs, it is immediately deleted without being retained by the retention rule.

You can add the same tag key and value pair to a maximum or five retention rules.

To create a Region-level retention rule, omit this parameter. A Region-level retention rule does not have any resource tags specified. It retains all deleted resources of the specified resource type in the Region in which the rule is created, even if the resources are not tagged.

  • (dict) --

    Information about the resource tags used to identify resources that are retained by the retention rule.

    • ResourceTagKey (string) -- [REQUIRED]

      The tag key.

    • ResourceTagValue (string) --

      The tag value.

rtype:

dict

returns:

Response Syntax

{
    'Identifier': 'string',
    'RetentionPeriod': {
        'RetentionPeriodValue': 123,
        'RetentionPeriodUnit': 'DAYS'
    },
    'Description': 'string',
    'ResourceType': 'EBS_SNAPSHOT'|'EC2_IMAGE',
    'ResourceTags': [
        {
            'ResourceTagKey': 'string',
            'ResourceTagValue': 'string'
        },
    ],
    'Status': 'pending'|'available'
}

Response Structure

  • (dict) --

    • Identifier (string) --

      The unique ID of the retention rule.

    • RetentionPeriod (dict) --

      Information about the retention period for which the retention rule is to retain resources.

      • RetentionPeriodValue (integer) --

        The period value for which the retention rule is to retain resources. The period is measured using the unit specified for RetentionPeriodUnit.

      • RetentionPeriodUnit (string) --

        The unit of time in which the retention period is measured. Currently, only DAYS is supported.

    • Description (string) --

      The retention rule description.

    • ResourceType (string) --

      The resource type retained by the retention rule.

    • ResourceTags (list) --

      Information about the resource tags used to identify resources that are retained by the retention rule.

      • (dict) --

        Information about the resource tags used to identify resources that are retained by the retention rule.

        • ResourceTagKey (string) --

          The tag key.

        • ResourceTagValue (string) --

          The tag value.

    • Status (string) --

      The state of the retention rule. Only retention rules that are in the available state retain resources.