CreateRule - Recycle Bin

CreateRule

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

Request Syntax

POST /rules HTTP/1.1 Content-type: application/json { "Description": "string", "ResourceTags": [ { "ResourceTagKey": "string", "ResourceTagValue": "string" } ], "ResourceType": "string", "RetentionPeriod": { "RetentionPeriodUnit": "string", "RetentionPeriodValue": number }, "Tags": [ { "Key": "string", "Value": "string" } ] }

URI Request Parameters

The request does not use any URI parameters.

Request Body

The request accepts the following data in JSON format.

Description

The retention rule description.

Type: String

Pattern: ^[\S ]{0,255}$

Required: No

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.

Type: Array of ResourceTag objects

Array Members: Minimum number of 0 items. Maximum number of 50 items.

Required: No

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: String

Valid Values: EBS_SNAPSHOT | EC2_IMAGE

Required: Yes

RetentionPeriod

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

Type: RetentionPeriod object

Required: Yes

Tags

Information about the tags to assign to the retention rule.

Type: Array of Tag objects

Array Members: Minimum number of 0 items. Maximum number of 50 items.

Required: No

Response Syntax

HTTP/1.1 201 Content-type: application/json { "Description": "string", "Identifier": "string", "ResourceTags": [ { "ResourceTagKey": "string", "ResourceTagValue": "string" } ], "ResourceType": "string", "RetentionPeriod": { "RetentionPeriodUnit": "string", "RetentionPeriodValue": number }, "Status": "string", "Tags": [ { "Key": "string", "Value": "string" } ] }

Response Elements

If the action is successful, the service sends back an HTTP 201 response.

The following data is returned in JSON format by the service.

Description

The retention rule description.

Type: String

Pattern: ^[\S ]{0,255}$

Identifier

The unique ID of the retention rule.

Type: String

Pattern: [0-9a-zA-Z]{11}

ResourceTags

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

Type: Array of ResourceTag objects

Array Members: Minimum number of 0 items. Maximum number of 50 items.

ResourceType

The resource type retained by the retention rule.

Type: String

Valid Values: EBS_SNAPSHOT | EC2_IMAGE

RetentionPeriod

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

Type: RetentionPeriod object

Status

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

Type: String

Valid Values: pending | available

Tags

Information about the tags assigned to the retention rule.

Type: Array of Tag objects

Array Members: Minimum number of 0 items. Maximum number of 50 items.

Errors

For information about the errors that are common to all actions, see Common Errors.

InternalServerException

The service could not respond to the request due to an internal problem.

HTTP Status Code: 500

ServiceQuotaExceededException

The request would cause a service quota for the number of tags per resource to be exceeded.

HTTP Status Code: 402

ValidationException

One or more of the parameters in the request is not valid.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: