update_lifecycle_policy
async
¶
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[AsyncimagebuilderClientConfig] = 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.
>>> await 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/async_imagebuilder.py
6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 | |