The goal:

You have AWS load-balancer with spot-instances. You need the engine starting spot instances automatically when existing ones die.

Then just three steps:

as-create-launch-config phabricator-fe-lc --image-id ami-4b8d2622 --instance-type t1.micro --spot-price 0.02

as-create-auto-scaling-group phabricator-fe-group-d --launch-configuration phabricator-fe-lc --availability-zones us-east-1d --min-size=1 --max-size=1 --default-cooldown 180 --grace-period 240 --health-check-type ELB --load-balancers phabricator


 as-create-auto-scaling-group phabricator-fe-group-c --launch-configuration phabricator-fe-lc --availability-zones us-east-1c --min-size=1 --max-size=1 --default-cooldown 180 --grace-period 240 --health-check-type ELB --load-balancers phabricator

Done!

Sure you have to have load-balancer up and running :)

Starting spot instance procedure can take time. If you want your instance up and running as fast as possible create launch configuration and auto-scaling group for OnDemand instance:

as-create-launch-config phabricator-fe-lc-demand --image-id ami-4b8d2622 --instance-type t1.micro


as-create-auto-scaling-group phabricator-fe-group-demand --launch-configuration phabricator-fe-lc-demand --availability-zones us-east-1d --min-size=0 --max-size=1 --default-cooldown 180 --grace-period 240 --health-check-type ELB --load-balancers phabricator

Then create two policies up and down:

as-put-scaling-policy on-demand-up-policy --auto-scaling-group phabricator-fe-group-demand --adjustment=1 --type ChangeInCapacity

as-put-scaling-policy on-demand-down-policy --auto-scaling-group phabricator-fe-group-demand --adjustment=-1 --type ChangeInCapacity

You are almost there!

Now go to Cloud Watch Web UI and create whatever Alarm you need for starting On-Demand and Terminating On-Demand instance.

I created for Starting: 

HealthyHostCount < 1 for 1 minutes

For Terminating:

HealthyHostCount > 1 for 1 minutes

If you need notifications when new instance is being started:

as-put-notification-configuration phabricator-fe-group-demand -t arn:aws:sns:us-east-1:758139277749:Phabricator -n autoscaling:EC2_INSTANCE_LAUNCH


References:


http://aws.amazon.com/autoscaling/
http://docs.amazonwebservices.com/AutoScaling/latest/DeveloperGuide/AS_Concepts.html


If you change ami, do this:


as-update-auto-scaling-group phabricator-fe-group-c --min-size 0
as-update-auto-scaling-group phabricator-fe-group-d --min-size 0

as-describe-auto-scaling-groups
... (all instances will be listed here)

as-terminate-instance-in-auto-scaling-group i-c9a576b5 --no-decrement-desired-capacity


as-create-launch-config phabricator-fe-lc-demand1 --image-id  ami-bcec54d5 --instance-type t1.micro

as-update-auto-scaling-group phabricator-fe-group-demand --launch-configuration phabricator-fe-lc-demand1


as-delete-launch-config  phabricator-fe-lc





6

View comments

Blog Archive
About Me
About Me
Loading