| Did this page help you? Yes No Tell us about it... |
In this example, you completely shut down an application that uses Auto Scaling, Elastic Load Balancing and Amazon CloudWatch alarms. For an example of how to set up an Auto Scaling application that uses Elastic Load Balancing and Amazon CloudWatch alarms, see Auto Scaling With Alarms And Load Balancing.
All Amazon EC2 instances for an online application are shut down. All Auto Scaling groups and Amazon CloudWatch alarms associated with the application are deleted.
In this example, we assume you have an application (associated with a LoadBalancer named
MyLB) running on a set of Amazon EC2 instances in an Auto Scaling group named
MyAutoScalingGroup. The application is load-balanced, and
is also auto-scaled through corresponding scaling triggers:
MyHighCPUAlarm that initiates MyScaleUpPolicy
MyLowCPUAlarm that initiates MyScaleDownPolicy
![]() | Note |
|---|---|
This scenario is for an application that is both load-balanced and auto-scaled. If you aren't using Elastic Load Balancing, omit step 3 from the following examples. |
To shut down an auto-scaled, load-balanced application
Delete MyScalingGroup:
Call UpdateAutoScalingGroup with the following
parameters:
AutoScalingGroupName =
MyAutoScalingGroup
MinSize = 0
MaxSize = 0
Verify that your changes to MyAutoScalingGroup have
taken effect by doing the following:
Call DescribeAutoScalingGroups with
MyAutoScalingGroup as a request parameter to verify that there
are no instances left in the group.
Call DescribeScalingActivites with
MyAutoScalingGroup as a request parameter to verify that all
scaling activities have completed.
Call DeleteAutoScalingGroup with the following
parameters:
AutoScalingGroupName =
MyAutoScalingGroup
![]() | Note |
|---|---|
Auto Scaling deletes any policies associated with the Auto Scaling group you are deleting. |
Call DeleteLaunchConfiguration with the following
parameters:
LaunchConfigurationName =
MyLC
Call DeleteAlarms from the Amazon CloudWatch API with the following
parameters:
AlarmNames.member.1 =
MyHighCPUAlarm
AlarmNames.member.2 =
MyLowCPUAlarm
Delete the LoadBalancer.
Call DeleteLoadBalancer from the Elastic Load Balancing API with the following
parameters:
LoadBalancerName = MyLB
The application is completely shut down.
For documentation on DeleteLoadBalancer, refer to the API Reference of the Elastic Load Balancing Developer Guide.
To shut down an auto-scaled, load-balanced application
Delete MyAutoScalingGroup:
Use the Auto Scaling as-update-auto-scaling-group
command to change the minimum and maximum size.
PROMPT>as-update-auto-scaling-group MyAutoScalingGroup --min-size 0 --max-size 0Auto Scaling returns the following:
OK-AutoScaling Group updated
Verify that no instances are in your Auto Scaling group by using the Auto Scaling as-describe-auto-scaling-groups command.
PROMPT>as-describe-auto-scaling-groups MyAutoScalingGroup --headersAuto Scaling might report that the state of your instances is Terminating
because the termination process can take a few minutes:
AUTO-SCALING-GROUP GROUP-NAME LAUNCH-CONFIG AVAILABILITY-ZONES MIN-SIZE MAX-SIZE DESIRED-CAPACITY AUTO-SCALING-GROUP MyAutoScalingGroup MyLC us-east-1a 0 0 0 INSTANCE INSTANCE-ID AVAILABILITY-ZONE STATE STATUS LAUNCH-CONFIG INSTANCE i-xxxxxxxx us-east-1b Terminating Healthy MyLC INSTANCE i-xxxxxxxx us-east-1a Terminating Healthy MyLC
After the termination process completes, calls to this command will report that no more instances remain in the Auto Scaling group:
AUTO-SCALING-GROUP GROUP-NAME LAUNCH-CONFIG AVAILABILITY-ZONES MIN-SIZE MAX-SIZE DESIRED-CAPACITY AUTO-SCALING-GROUP MyAutoScalingGroup MyLC us-east-1a 0 0 0
Use the Auto Scaling as-delete-auto-scaling-group command.
PROMPT>as-delete-auto-scaling-group MyAutoScalingGroupAuto Scaling returns the following:
Are you sure you want to delete this AutoScalingGroup? [Ny]
Enter y to delete the AutoScalingGroup.
Auto Scaling returns the following:
OK-Deleted AutoScalingGroup
![]() | Note |
|---|---|
Auto Scaling deletes any policies associated with the Auto Scaling group you are deleting. |
Use the Auto Scaling as-delete-launch-config command to delete the launch configuration.
PROMPT>as-delete-launch-config MyLCAuto Scaling returns the following:
Are you sure you want to delete this launch configuration? [Ny]
Enter y to delete the Launch Configuration.
Auto Scaling returns the following:
OK-Deleted launch configuration
Delete the Amazon CloudWatch alarms.
Use the Amazon CloudWatch mon-delete-alarms
command.
PROMPT>mon-delete-alarms MyHighCPUAlarm MyLowCPUAlarmAuto Scaling returns the following:
Are you sure you want to delete these alarms? [Ny]y
Enter y to delete the alarms.
Auto Scaling returns the following:
OK-Deleted alarms
Delete the load balancer with the Elastic Load Balancing elb-delete-lb command.
PROMPT>elb-delete-lb MyLBElastic Load Balancing returns the following:
Warning: Deleting a LoadBalancer can lead to service disruption to any customers connected to the LoadBalancer. Are you sure you want to delete this LoadBalancer? [Ny]
Enter y to delete the LoadBalancer
Elastic Load Balancing returns the following:
OK-Deleting LoadBalancer
The application is completely shut down.