Skip to content

delete_policy async

delete_policy(
    *,
    config_overrides: Optional[AsyncAutoScalingClientConfig] = None,
    auto_scaling_group_name: Optional[XmlStringMaxLen255] = None,
    policy_name: Optional[ResourceName] = None,
) -> None

Deletes the specified scaling policy.

Deleting either a step scaling policy or a simple scaling policy deletes the underlying alarm action, but does not delete the alarm, even if it no longer has an associated action.

For more information, see Delete a scaling policy in the Amazon EC2 Auto Scaling User Guide.

Parameters:

Raises:

  • ResourceContentionFault –

    You already have a pending update to an Amazon EC2 Auto Scaling resource (for example, an Auto Scaling group, instance, or load balancer).

  • ServiceLinkedRoleFailure –

    The service-linked role is not yet ready for use.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Examples:

To delete an Auto Scaling policy This example deletes the specified Auto Scaling policy.

>>> await client.delete_policy(auto_scaling_group_name='my-auto-scaling-group', policy_name='my-step-scale-out-policy')
Source code in docs_src/capo_auto_scaling/_services/async_auto_scaling.py
async def delete_policy(
    self,
    *,
    config_overrides: Optional[AsyncAutoScalingClientConfig] = None,
    auto_scaling_group_name: Optional[
        "capo_auto_scaling.types.xml_string_max_len255.XmlStringMaxLen255"
    ] = None,
    policy_name: Optional[
        "capo_auto_scaling.types.resource_name.ResourceName"
    ] = None,
) -> None:
    """<p>Deletes the specified scaling policy.</p> <p>Deleting either a step scaling policy or a simple scaling policy deletes the underlying alarm action, but does not delete the alarm, even if it no longer has an associated action.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/deleting-scaling-policy.html">Delete a scaling policy</a> in the <i>Amazon EC2 Auto Scaling User Guide</i>.</p>

    Args:
        auto_scaling_group_name: <p>The name of the Auto Scaling group.</p>
        policy_name: <p>The name or Amazon Resource Name (ARN) of the policy.</p>

    Raises:
        capo_auto_scaling.errors.resource_contention_fault.ResourceContentionFault: <p>You already have a pending update to an Amazon EC2 Auto Scaling resource (for example, an Auto Scaling group, instance, or load balancer).</p>
        capo_auto_scaling.errors.service_linked_role_failure.ServiceLinkedRoleFailure: <p>The service-linked role is not yet ready for use.</p>
        capo_auto_scaling.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To delete an Auto Scaling policy
        This example deletes the specified Auto Scaling policy.

        >>> await client.delete_policy(auto_scaling_group_name='my-auto-scaling-group', policy_name='my-step-scale-out-policy')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_auto_scaling.types.delete_policy_type.DeletePolicyType]",
    ) -> AsyncOperationResponse[None]:
        import capo_auto_scaling._operations.auto_scaling_2011_01_01.delete_policy

        (
            output,
            http_response,
        ) = await capo_auto_scaling._operations.auto_scaling_2011_01_01.delete_policy.async_delete_policy(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DeletePolicy")
    )
    input_: capo_auto_scaling.types.delete_policy_type.DeletePolicyType = {}
    if auto_scaling_group_name is not None:
        input_["auto_scaling_group_name"] = auto_scaling_group_name
    if policy_name is not None:
        input_["policy_name"] = policy_name

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