Skip to content

delete_auto_scaling_group async

delete_auto_scaling_group(
    *,
    config_overrides: Optional[AsyncAutoScalingClientConfig] = None,
    auto_scaling_group_name: Optional[XmlStringMaxLen255] = None,
    force_delete: Optional[ForceDelete] = None,
) -> None

Deletes the specified Auto Scaling group.

If the group has instances or scaling activities in progress, you must specify the option to force the deletion in order for it to succeed. The force delete operation will also terminate the EC2 instances. If the group has a warm pool, the force delete option also deletes the warm pool.

To remove instances from the Auto Scaling group before deleting it, call the DetachInstances API with the list of instances and the option to decrement the desired capacity. This ensures that Amazon EC2 Auto Scaling does not launch replacement instances.

To terminate all instances before deleting the Auto Scaling group, call the UpdateAutoScalingGroup API and set the minimum size and desired capacity of the Auto Scaling group to zero.

If the group has scaling policies, deleting the group deletes the policies, the underlying alarm actions, and any alarm that no longer has an associated action.

For more information, see Delete your Auto Scaling infrastructure in the Amazon EC2 Auto Scaling User Guide.

Parameters:

  • auto_scaling_group_name (Optional[XmlStringMaxLen255], default: None ) –

    The name of the Auto Scaling group.

  • force_delete (Optional[ForceDelete], default: None ) –

    Specifies that the group is to be deleted along with all instances associated with the group, without waiting for all instances to be terminated. This action also deletes any outstanding lifecycle actions associated with the group.

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).

  • ResourceInUseFault –

    The operation can't be performed because the resource is in use.

  • ScalingActivityInProgressFault –

    The operation can't be performed because there are scaling activities in progress.

  • UnknownServiceError –

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

Examples:

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

>>> await client.delete_auto_scaling_group(auto_scaling_group_name='my-auto-scaling-group')
To delete an Auto Scaling group and all its instances
This example deletes the specified Auto Scaling group and all its instances.
>>> await client.delete_auto_scaling_group(auto_scaling_group_name='my-auto-scaling-group', force_delete=True)
Source code in docs_src/capo_auto_scaling/_services/async_auto_scaling.py
async def delete_auto_scaling_group(
    self,
    *,
    config_overrides: Optional[AsyncAutoScalingClientConfig] = None,
    auto_scaling_group_name: Optional[
        "capo_auto_scaling.types.xml_string_max_len255.XmlStringMaxLen255"
    ] = None,
    force_delete: Optional[
        "capo_auto_scaling.types.force_delete.ForceDelete"
    ] = None,
) -> None:
    """<p>Deletes the specified Auto Scaling group.</p> <p>If the group has instances or scaling activities in progress, you must specify the option to force the deletion in order for it to succeed. The force delete operation will also terminate the EC2 instances. If the group has a warm pool, the force delete option also deletes the warm pool.</p> <p>To remove instances from the Auto Scaling group before deleting it, call the <a href="https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_DetachInstances.html">DetachInstances</a> API with the list of instances and the option to decrement the desired capacity. This ensures that Amazon EC2 Auto Scaling does not launch replacement instances.</p> <p>To terminate all instances before deleting the Auto Scaling group, call the <a href="https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_UpdateAutoScalingGroup.html">UpdateAutoScalingGroup</a> API and set the minimum size and desired capacity of the Auto Scaling group to zero.</p> <p>If the group has scaling policies, deleting the group deletes the policies, the underlying alarm actions, and any alarm that no longer has an associated action.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-process-shutdown.html">Delete your Auto Scaling infrastructure</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>
        force_delete: <p>Specifies that the group is to be deleted along with all instances associated with the group, without waiting for all instances to be terminated. This action also deletes any outstanding lifecycle actions associated with the group.</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.resource_in_use_fault.ResourceInUseFault: <p>The operation can't be performed because the resource is in use.</p>
        capo_auto_scaling.errors.scaling_activity_in_progress_fault.ScalingActivityInProgressFault: <p>The operation can't be performed because there are scaling activities in progress.</p>
        capo_auto_scaling.errors.UnknownServiceError: The service returned an error code this client does not model.

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

        >>> await client.delete_auto_scaling_group(auto_scaling_group_name='my-auto-scaling-group')
        To delete an Auto Scaling group and all its instances
        This example deletes the specified Auto Scaling group and all its instances.

        >>> await client.delete_auto_scaling_group(auto_scaling_group_name='my-auto-scaling-group', force_delete=True)
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_auto_scaling.types.delete_auto_scaling_group_type.DeleteAutoScalingGroupType]",
    ) -> AsyncOperationResponse[None]:
        import capo_auto_scaling._operations.auto_scaling_2011_01_01.delete_auto_scaling_group

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DeleteAutoScalingGroup")
    )
    input_: capo_auto_scaling.types.delete_auto_scaling_group_type.DeleteAutoScalingGroupType = {}
    if auto_scaling_group_name is not None:
        input_["auto_scaling_group_name"] = auto_scaling_group_name
    if force_delete is not None:
        input_["force_delete"] = force_delete

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