- Navigation GuideYou are on a Command (operation) page with structural examples. Use the navigation breadcrumb if you would like to return to the Client landing page.
DeleteAutoScalingGroupCommand
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.
Example Syntax
Use a bare-bones client and the command you need to make an API call.
import { AutoScalingClient, DeleteAutoScalingGroupCommand } from "@aws-sdk/client-auto-scaling"; // ES Modules import
// const { AutoScalingClient, DeleteAutoScalingGroupCommand } = require("@aws-sdk/client-auto-scaling"); // CommonJS import
const client = new AutoScalingClient(config);
const input = { // DeleteAutoScalingGroupType
AutoScalingGroupName: "STRING_VALUE", // required
ForceDelete: true || false,
};
const command = new DeleteAutoScalingGroupCommand(input);
const response = await client.send(command);
// {};
Example Usage
DeleteAutoScalingGroupCommand Input
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
AutoScalingGroupName Required | string | undefined | The name of the Auto Scaling group. |
ForceDelete | boolean | undefined | 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. |
DeleteAutoScalingGroupCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
Throws
Name | Fault | Details |
---|
Name | Fault | Details |
---|---|---|
ResourceContentionFault | server | You already have a pending update to an Amazon EC2 Auto Scaling resource (for example, an Auto Scaling group, instance, or load balancer). |
ResourceInUseFault | client | The operation can't be performed because the resource is in use. |
ScalingActivityInProgressFault | client | The operation can't be performed because there are scaling activities in progress. |
AutoScalingServiceException | Base exception class for all service exceptions from AutoScaling service. |