Skip to content

update_lifecycle_policy async

update_lifecycle_policy(
    policy_id: PolicyId,
    *,
    config_overrides: Optional[AsyncDLMClientConfig] = None,
    execution_role_arn: Optional[ExecutionRoleArn] = None,
    state: Optional[SettablePolicyStateValues] = None,
    description: Optional[PolicyDescription] = None,
    policy_details: Optional[PolicyDetails] = None,
    create_interval: Optional[CreateInterval] = None,
    retain_interval: Optional[RetainInterval] = None,
    copy_tags: Optional[CopyTagsNullable] = None,
    extend_deletion: Optional[ExtendDeletion] = None,
    cross_region_copy_targets: Optional[CrossRegionCopyTargetList] = None,
    exclusions: Optional[Exclusions] = None,
) -> UpdateLifecyclePolicyResponse

Updates the specified lifecycle policy.

For more information about updating a policy, see Modify lifecycle policies.

Parameters:

  • policy_id (PolicyId) –

    The identifier of the lifecycle policy.

  • execution_role_arn (Optional[ExecutionRoleArn], default: None ) –

    The Amazon Resource Name (ARN) of the IAM role used to run the operations specified by the lifecycle policy.

  • state (Optional[SettablePolicyStateValues], default: None ) –

    The desired activation state of the lifecycle policy after creation.

  • description (Optional[PolicyDescription], default: None ) –

    A description of the lifecycle policy.

  • policy_details (Optional[PolicyDetails], default: None ) –

    The configuration of the lifecycle policy. You cannot update the policy type or the resource type.

  • create_interval (Optional[CreateInterval], default: None ) –

    [Default policies only] Specifies how often the policy should run and create snapshots or AMIs. The creation frequency can range from 1 to 7 days.

  • retain_interval (Optional[RetainInterval], default: None ) –

    [Default policies only] Specifies how long the policy should retain snapshots or AMIs before deleting them. The retention period can range from 2 to 14 days, but it must be greater than the creation frequency to ensure that the policy retains at least 1 snapshot or AMI at any given time.

  • copy_tags (Optional[CopyTagsNullable], default: None ) –

    [Default policies only] Indicates whether the policy should copy tags from the source resource to the snapshot or AMI.

  • extend_deletion (Optional[ExtendDeletion], default: None ) –

    [Default policies only] Defines the snapshot or AMI retention behavior for the policy if the source volume or instance is deleted, or if the policy enters the error, disabled, or deleted state.

    By default (ExtendDeletion=false):

    • If a source resource is deleted, Amazon Data Lifecycle Manager will continue to delete previously created snapshots or AMIs, up to but not including the last one, based on the specified retention period. If you want Amazon Data Lifecycle Manager to delete all snapshots or AMIs, including the last one, specify true.

    • If a policy enters the error, disabled, or deleted state, Amazon Data Lifecycle Manager stops deleting snapshots and AMIs. If you want Amazon Data Lifecycle Manager to continue deleting snapshots or AMIs, including the last one, if the policy enters one of these states, specify true.

    If you enable extended deletion (ExtendDeletion=true), you override both default behaviors simultaneously.

    Default: false

  • cross_region_copy_targets (Optional[CrossRegionCopyTargetList], default: None ) –

    [Default policies only] Specifies destination Regions for snapshot or AMI copies. You can specify up to 3 destination Regions. If you do not want to create cross-Region copies, omit this parameter.

  • exclusions (Optional[Exclusions], default: None ) –

    [Default policies only] Specifies exclusion parameters for volumes or instances for which you do not want to create snapshots or AMIs. The policy will not create snapshots or AMIs for target resources that match any of the specified exclusion parameters.

Raises:

Source code in docs_src/capo_dlm/_services/async_dlm.py
async def update_lifecycle_policy(
    self,
    policy_id: "capo_dlm.types.policy_id.PolicyId",
    *,
    config_overrides: Optional[AsyncDLMClientConfig] = None,
    execution_role_arn: Optional[
        "capo_dlm.types.execution_role_arn.ExecutionRoleArn"
    ] = None,
    state: Optional[
        "capo_dlm.types.settable_policy_state_values.SettablePolicyStateValues"
    ] = None,
    description: Optional[
        "capo_dlm.types.policy_description.PolicyDescription"
    ] = None,
    policy_details: Optional["capo_dlm.types.policy_details.PolicyDetails"] = None,
    create_interval: Optional[
        "capo_dlm.types.create_interval.CreateInterval"
    ] = None,
    retain_interval: Optional[
        "capo_dlm.types.retain_interval.RetainInterval"
    ] = None,
    copy_tags: Optional[
        "capo_dlm.types.copy_tags_nullable.CopyTagsNullable"
    ] = None,
    extend_deletion: Optional[
        "capo_dlm.types.extend_deletion.ExtendDeletion"
    ] = None,
    cross_region_copy_targets: Optional[
        "capo_dlm.types.cross_region_copy_target_list.CrossRegionCopyTargetList"
    ] = None,
    exclusions: Optional["capo_dlm.types.exclusions.Exclusions"] = None,
) -> (
    "capo_dlm.types.update_lifecycle_policy_response.UpdateLifecyclePolicyResponse"
):
    """<p>Updates the specified lifecycle policy.</p> <p>For more information about updating a policy, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/view-modify-delete.html#modify">Modify lifecycle policies</a>.</p>

    Args:
        policy_id: <p>The identifier of the lifecycle policy.</p>
        execution_role_arn: <p>The Amazon Resource Name (ARN) of the IAM role used to run the operations specified by the lifecycle policy.</p>
        state: <p>The desired activation state of the lifecycle policy after creation.</p>
        description: <p>A description of the lifecycle policy.</p>
        policy_details: <p>The configuration of the lifecycle policy. You cannot update the policy type or the resource type.</p>
        create_interval: <p> <b>[Default policies only]</b> Specifies how often the policy should run and create snapshots or AMIs. The creation frequency can range from 1 to 7 days.</p>
        retain_interval: <p> <b>[Default policies only]</b> Specifies how long the policy should retain snapshots or AMIs before deleting them. The retention period can range from 2 to 14 days, but it must be greater than the creation frequency to ensure that the policy retains at least 1 snapshot or AMI at any given time.</p>
        copy_tags: <p> <b>[Default policies only]</b> Indicates whether the policy should copy tags from the source resource to the snapshot or AMI.</p>
        extend_deletion: <p> <b>[Default policies only]</b> Defines the snapshot or AMI retention behavior for the policy if the source volume or instance is deleted, or if the policy enters the error, disabled, or deleted state.</p> <p>By default (<b>ExtendDeletion=false</b>):</p> <ul> <li> <p>If a source resource is deleted, Amazon Data Lifecycle Manager will continue to delete previously created snapshots or AMIs, up to but not including the last one, based on the specified retention period. If you want Amazon Data Lifecycle Manager to delete all snapshots or AMIs, including the last one, specify <code>true</code>.</p> </li> <li> <p>If a policy enters the error, disabled, or deleted state, Amazon Data Lifecycle Manager stops deleting snapshots and AMIs. If you want Amazon Data Lifecycle Manager to continue deleting snapshots or AMIs, including the last one, if the policy enters one of these states, specify <code>true</code>.</p> </li> </ul> <p>If you enable extended deletion (<b>ExtendDeletion=true</b>), you override both default behaviors simultaneously.</p> <p>Default: false</p>
        cross_region_copy_targets: <p> <b>[Default policies only]</b> Specifies destination Regions for snapshot or AMI copies. You can specify up to 3 destination Regions. If you do not want to create cross-Region copies, omit this parameter.</p>
        exclusions: <p> <b>[Default policies only]</b> Specifies exclusion parameters for volumes or instances for which you do not want to create snapshots or AMIs. The policy will not create snapshots or AMIs for target resources that match any of the specified exclusion parameters.</p>

    Raises:
        capo_dlm.errors.internal_server_exception.InternalServerException: <p>The service failed in an unexpected way.</p>
        capo_dlm.errors.invalid_request_exception.InvalidRequestException: <p>Bad request. The request is missing required parameters or has invalid parameters.</p>
        capo_dlm.errors.limit_exceeded_exception.LimitExceededException: <p>The request failed because a limit was exceeded.</p>
        capo_dlm.errors.resource_not_found_exception.ResourceNotFoundException: <p>A requested resource was not found.</p>
        capo_dlm.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_dlm.types.update_lifecycle_policy_request.UpdateLifecyclePolicyRequest]",
    ) -> AsyncOperationResponse[
        "capo_dlm.types.update_lifecycle_policy_response.UpdateLifecyclePolicyResponse"
    ]:
        import capo_dlm._operations.dlm_20180112.update_lifecycle_policy

        (
            output,
            http_response,
        ) = await capo_dlm._operations.dlm_20180112.update_lifecycle_policy.async_update_lifecycle_policy(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateLifecyclePolicy")
    )
    input_: capo_dlm.types.update_lifecycle_policy_request.UpdateLifecyclePolicyRequest = {
        "policy_id": policy_id
    }
    if execution_role_arn is not None:
        input_["execution_role_arn"] = execution_role_arn
    if state is not None:
        input_["state"] = state
    if description is not None:
        input_["description"] = description
    if policy_details is not None:
        input_["policy_details"] = policy_details
    if create_interval is not None:
        input_["create_interval"] = create_interval
    if retain_interval is not None:
        input_["retain_interval"] = retain_interval
    if copy_tags is not None:
        input_["copy_tags"] = copy_tags
    if extend_deletion is not None:
        input_["extend_deletion"] = extend_deletion
    if cross_region_copy_targets is not None:
        input_["cross_region_copy_targets"] = cross_region_copy_targets
    if exclusions is not None:
        input_["exclusions"] = exclusions

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output