update_lifecycle_policy
¶
update_lifecycle_policy(
lifecycle_policy_arn: LifecyclePolicyArn,
execution_role: RoleNameOrArn,
resource_type: LifecyclePolicyResourceType,
policy_details: LifecyclePolicyDetails,
resource_selection: LifecyclePolicyResourceSelection,
client_token: ClientToken,
*,
config_overrides: Optional[imagebuilderClientConfig] = None,
description: Optional[NonEmptyString] = None,
status: Optional[LifecyclePolicyStatus] = None,
) -> UpdateLifecyclePolicyResponse
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.
Parameters:
-
lifecycle_policy_arn(LifecyclePolicyArn) –The Amazon Resource Name (ARN) of the lifecycle policy resource.
-
description(Optional[NonEmptyString], default:None) –Optional description for the lifecycle policy. Because the update replaces the entire configuration, omitting this property removes any existing description.
-
status(Optional[LifecyclePolicyStatus], default:None) –Indicates whether the lifecycle policy resource is enabled. Defaults to
ENABLEDwhen omitted, so updating a disabled policy without setting this property re-enables it. -
execution_role(RoleNameOrArn) –The name or Amazon Resource Name (ARN) for the IAM role you create that grants Image Builder access to run lifecycle actions.
-
resource_type(LifecyclePolicyResourceType) –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.
-
policy_details(LifecyclePolicyDetails) –The configuration details for a lifecycle policy resource.
-
resource_selection(LifecyclePolicyResourceSelection) –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.
-
client_token(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.
Raises:
-
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.
-
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.
-
ForbiddenException–You are not authorized to perform the requested operation.
-
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.
-
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.
-
InvalidRequestException–The request is malformed or otherwise invalid. Verify the request and try again.
-
ResourceInUseException–The resource that you are trying to operate on is currently in use. Review the message details and retry later.
-
ServiceException–An internal server error occurred while Image Builder processed the request. Retrying the request may succeed.
-
ServiceUnavailableException–The service is unable to process your request at this time.
-
UnknownServiceError–The service returned an error code this client does not model.
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.
>>> client.update_lifecycle_policy(lifecycle_policy_arn='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', execution_role='arn:aws:iam::111122223333:role/my-example-lifecycle-role', resource_type='AMI_IMAGE', policy_details=[{'action': {'type': 'DELETE', 'includeResources': {'amis': True, 'snapshots': True}}, 'filter': {'type': 'AGE', 'value': 12, 'unit': 'MONTHS', 'retainAtLeast': 3}}], resource_selection={'tagMap': {'environment': 'production'}}, client_token='a1b2c3d4-5678-90ab-cdef-EXAMPLEaaaaa')
Source code in docs_src/capo_imagebuilder/_services/imagebuilder.py
6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 | |