UpdateLifecyclePolicy
Updates the specified lifecycle policy. The request replaces the existing
policy configuration rather than merging changes, so re-specify every setting
that you want to keep. The resourceType must match the existing
policy's value.
Request Syntax
PUT /UpdateLifecyclePolicy HTTP/1.1
Content-type: application/json
{
"clientToken": "string",
"description": "string",
"executionRole": "string",
"lifecyclePolicyArn": "string",
"policyDetails": [
{
"action": {
"includeResources": {
"amis": boolean,
"containers": boolean,
"snapshots": boolean
},
"type": "string"
},
"exclusionRules": {
"amis": {
"isPublic": boolean,
"lastLaunched": {
"unit": "string",
"value": number
},
"regions": [ "string" ],
"sharedAccounts": [ "string" ],
"tagMap": {
"string" : "string"
}
},
"tagMap": {
"string" : "string"
}
},
"filter": {
"retainAtLeast": number,
"type": "string",
"unit": "string",
"value": number
}
}
],
"resourceSelection": {
"recipes": [
{
"name": "string",
"semanticVersion": "string"
}
],
"tagMap": {
"string" : "string"
}
},
"resourceType": "string",
"status": "string"
}
URI Request Parameters
The request does not use any URI parameters.
Request Body
The request accepts the following data in JSON format.
- clientToken
-
A unique, case-sensitive identifier you provide to ensure that the operation runs no more than one time. If you retry a request with the same client token, Image Builder returns the original response without running the operation again. For more information, see Ensuring idempotency in the Amazon EC2 API Reference.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 64.
Required: Yes
- description
-
Optional description for the lifecycle policy. Because the update replaces the entire configuration, omitting this property removes any existing description.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 1024.
Required: No
- executionRole
-
The name or Amazon Resource Name (ARN) for the IAM role you create that grants Image Builder access to run lifecycle actions.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 2048.
Pattern:
^(?:arn:aws(?:-[a-z]+)*:iam::[0-9]{12}:role/)?[a-zA-Z_0-9+=,.@\-_/]+$Required: Yes
- lifecyclePolicyArn
-
The Amazon Resource Name (ARN) of the lifecycle policy resource.
Type: String
Length Constraints: Maximum length of 1024.
Pattern:
^arn:aws(?:-[a-z]+)*:imagebuilder:[a-z]{2,}(?:-[a-z]+)+-[0-9]+:(?:[0-9]{12}|aws):lifecycle-policy/[a-z0-9-_]+$Required: Yes
- policyDetails
-
The configuration details for a lifecycle policy resource.
Type: Array of LifecyclePolicyDetail objects
Array Members: Minimum number of 1 item. Maximum number of 3 items.
Required: Yes
- resourceSelection
-
Selection criteria for resources that the lifecycle policy applies to. You must specify exactly one selection criteria: either recipes or a tag map, not both.
Type: LifecyclePolicyResourceSelection object
Required: Yes
- resourceType
-
The type of image resource that the lifecycle policy applies to. The value must match the policy's existing resource type. You can't change the resource type of an existing lifecycle policy.
Type: String
Valid Values:
AMI_IMAGE | CONTAINER_IMAGERequired: Yes
- status
-
Indicates whether the lifecycle policy resource is enabled. Defaults to
ENABLEDwhen omitted, so updating a disabled policy without setting this property re-enables it.Type: String
Valid Values:
DISABLED | ENABLEDRequired: No
Response Syntax
HTTP/1.1 200
Content-type: application/json
{
"lifecyclePolicyArn": "string"
}
Response Elements
If the action is successful, the service sends back an HTTP 200 response.
The following data is returned in JSON format by the service.
- lifecyclePolicyArn
-
The Amazon Resource Name (ARN) of the image lifecycle policy resource that was updated.
Type: String
Length Constraints: Maximum length of 1024.
Pattern:
^arn:aws(?:-[a-z]+)*:imagebuilder:[a-z]{2,}(?:-[a-z]+)+-[0-9]+:(?:[0-9]{12}|aws):lifecycle-policy/[a-z0-9-_]+$
Errors
For information about the errors that are common to all actions, see Common Error Types.
- CallRateLimitExceededException
-
You have exceeded the permitted request rate for the Amazon EC2 APIs that Image Builder calls on your behalf. Retry with an increasing or variable delay between requests.
HTTP Status Code: 429
- ClientException
-
A generic client error. This error usually indicates that the request failed a validation check, such as when a downstream service rejects a configured value.
HTTP Status Code: 400
- ForbiddenException
-
You are not authorized to perform the requested operation.
HTTP Status Code: 403
- IdempotentParameterMismatchException
-
You have specified a client token for an operation using parameter values that differ from a previous request that used the same client token.
HTTP Status Code: 400
- InvalidParameterCombinationException
-
You have specified a combination of parameters that isn't valid. For example, two mutually exclusive parameters, or a parameter without its required companion parameter. Review the error message for details.
HTTP Status Code: 400
- InvalidRequestException
-
The request is malformed or otherwise invalid. Verify the request and try again.
HTTP Status Code: 400
- ResourceInUseException
-
The resource that you are trying to operate on is currently in use. Review the message details and retry later.
HTTP Status Code: 400
- ServiceException
-
An internal server error occurred while Image Builder processed the request. Retrying the request may succeed.
HTTP Status Code: 500
- ServiceUnavailableException
-
The service is unable to process your request at this time.
HTTP Status Code: 503
Examples
Update a lifecycle policy
The following example updates a lifecycle policy to delete AMI images and their associated snapshots after 12 months, retaining the 3 most recent images.
Sample Request
PUT /UpdateLifecyclePolicy HTTP/1.1
Content-type: application/json
{
"lifecyclePolicyArn": "arn:aws:imagebuilder:us-west-2:111122223333:lifecycle-policy/my-example-policy",
"description": "Deletes AMI images and their snapshots after 12 months, retaining the 3 most recent",
"status": "ENABLED",
"executionRole": "arn:aws:iam::111122223333:role/my-example-lifecycle-role",
"resourceType": "AMI_IMAGE",
"policyDetails": [
{
"action": {
"type": "DELETE",
"includeResources": {
"amis": true,
"snapshots": true
}
},
"filter": {
"type": "AGE",
"value": 12,
"unit": "MONTHS",
"retainAtLeast": 3
}
}
],
"resourceSelection": {
"tagMap": {
"environment": "production"
}
},
"clientToken": "a1b2c3d4-5678-90ab-cdef-EXAMPLEaaaaa"
}
Sample Response
HTTP/1.1 200
Content-type: application/json
{
"lifecyclePolicyArn": "arn:aws:imagebuilder:us-west-2:111122223333:lifecycle-policy/my-example-policy"
}
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: