### System environment settings ###
In Your bashrc:
export AWS_AUTO_SCALING_HOME=/data/aws-keys/as
export AWS_CREDENTIAL_FILE=/data/aws-keys/as/credential-file-path.template
I believe you already have JAVA_HOME :)
And for AutoScaling cmd API location:
http://ec2-downloads.s3.amazonaws.com/AutoScaling-2011-01-01.zip
You can also go to the following link to get the above command location:
http://docs.aws.amazon.com/AutoScaling/latest/DeveloperGuide/UsingTheCommandLineTools.html#setting-up-your-tools
Go to above link, and select Auto Scaling Command Line Tools To get the following location.
http://aws.amazon.com/developertools/2535?_encoding=UTF8&jiveRedirect=1
#### Starting Auto scalling sample ####
amit@amitAsus:~$ as-create-launch-config MyCmdASLaunchConfig --image-id <Your ami> --instance-type m1.small
OK-Created launch config
amit@amitAsus:~$ as-describe-launch-configs
LAUNCH-CONFIG MyCmdASLaunchConfig <Your ami> m1.small
NOTE: Do not forget to provide at-least the security group and the key information.
amit@amitAsus:~$ as-create-auto-scaling-group MyCmdASGroup --launch-configuration MyCmdASLaunchConfig --availability-zones us-east-1e --min-size 1 --max-size 2 --desired-capacity 1
OK-Created AutoScalingGroup
amit@amitAsus:~$ as-describe-auto-scaling-groups
AUTO-SCALING-GROUP MyCmdASGroup MyCmdASLaunchConfig us-east-1e 1 2 1 Default
INSTANCE i-b94ac699 us-east-1e InService Healthy MyCmdASLaunchConfig
amit@amitAsus:~$ as-describe-auto-scaling-groups --headers
AUTO-SCALING-GROUP GROUP-NAME LAUNCH-CONFIG AVAILABILITY-ZONES MIN-SIZE MAX-SIZE DESIRED-CAPACITY TERMINATION-POLICIES
AUTO-SCALING-GROUP MyCmdASGroup MyCmdASLaunchConfig us-east-1e 1 2 1 Default
INSTANCE INSTANCE-ID AVAILABILITY-ZONE STATE STATUS LAUNCH-CONFIG
INSTANCE i-b94ac699 us-east-1e InService Healthy MyCmdASLaunchConfig
amit@amitAsus:~$ as-describe-auto-scaling-instances
INSTANCE i-b94ac699 MyCmdASGroup us-east-1e InService HEALTHY MyCmdASLaunchConfig
######## For deleting #######
If you have not updated the Auto-scaling-group to have min 0 then you will get the following error:
amit@amitAsus:~$ as-delete-auto-scaling-group MyCmdASGroup
Are you sure you want to delete this AutoScalingGroup? [Ny]y
as-delete-auto-scaling-group: Malformed input-You cannot delete an AutoScalingGroup while there are instances
or pending Spot instance request(s) still in the group.
Usage:
as-delete-auto-scaling-group
AutoScalingGroupName [--force-delete ] [General Options]
For more information and a full list of options, run "as-delete-auto-scaling-group --help"
IMP: NOTE: If the user wants to terminate all the instances, first update the Auto Scaling group with the following command: [ To have min-size '0' ]
amit@amitAsus:~$ as-update-auto-scaling-group MyCmdASGroup --min-size 0
OK-Updated AutoScalingGroup
amit@amitAsus:~$ as-describe-auto-scaling-groups
AUTO-SCALING-GROUP MyCmdASGroup MyCmdASLaunchConfig us-east-1e 0 2 1 Default
INSTANCE i-b94ac699 us-east-1e InService Healthy MyCmdASLaunchConfig
amit@amitAsus:~$ as-describe-auto-scaling-groups --headers
AUTO-SCALING-GROUP GROUP-NAME LAUNCH-CONFIG AVAILABILITY-ZONES MIN-SIZE MAX-SIZE DESIRED-CAPACITY TERMINATION-POLICIES
AUTO-SCALING-GROUP MyCmdASGroup MyCmdASLaunchConfig us-east-1e 0 2 1 Default
INSTANCE INSTANCE-ID AVAILABILITY-ZONE STATE STATUS LAUNCH-CONFIG
INSTANCE i-b94ac699 us-east-1e InService Healthy MyCmdASLaunchConfig
# Now terminate the instance in auto-scaling-group:
INPUT EXAMPLES
Terminates instance 'i-1' and decrements group size.
$PROMPT> as-terminate-instance-in-auto-scaling-group i-1 --decrement-desired-capacity
Terminates instance 'i-2' but does not decrement the group size.
$PROMPT> as-terminate-instance-in-auto-scaling-group i-2 --no-decrement-desired-capacity
amit@amitAsus:~$ as-terminate-instance-in-auto-scaling-group i-b94ac699 --decrement-desired-capacity
Are you sure you want to terminate this instance? [Ny]y
INSTANCE 2d7fc3b8-e725-4b4e-b433-9364f5e6fabe InProgress At 2013-12-31T18:48:53Z instance i-b94ac699 was taken out of service in response to a user request, shrinking the capacity from 1 to 0.
# Now you can delete the auto-scaling group:
amit@amitAsus:~$ as-delete-auto-scaling-group MyCmdASGroup
Are you sure you want to delete this AutoScalingGroup? [Ny]y
OK-Deleted AutoScalingGroup
amit@amitAsus:~$ as-describe-auto-scaling-groups
AUTO-SCALING-GROUP MyCmdASGroup MyCmdASLaunchConfig us-east-1e 0 0 0 Default
amit@amitAsus:~$ as-describe-auto-scaling-instances
No instances found
amit@amitAsus:~$ as-describe-auto-scaling-groups
No AutoScalingGroups found
amit@amitAsus:~$ as-describe-launch-configs
LAUNCH-CONFIG MyCmdASLaunchConfig ami-f5381c9c m1.small
amit@amitAsus:~$ as-delete-launch-config MyCmdASLaunchConfig
Are you sure you want to delete this launch configuration? [Ny]y
OK-Deleted launch configuration
amit@amitAsus:~$ as-describe-launch-configs
No launch configurations found
NOTE: On Scripting, you might need to wait for some time after issuing few commands because, it takes some time, to give you rest of the information of do a recheck of the expected command out-out.
Few Ref Link:
http://docs.aws.amazon.com/AutoScaling/latest/DeveloperGuide/WhatIsAutoScaling.html
http://docs.aws.amazon.com/AutoScaling/latest/DeveloperGuide/US_BasicSetup.html
http://www.newvem.com/how-to-create-update-and-delete-an-aws-auto-scaling-group/
No comments:
Post a Comment