How to use Amazon Web Services Auto Scaling Groups

This post we will cover all the commands to create and managed Amazons Auto Scaling Groups

What is an Auto Scaling Group?

Auto Scaling allows you to scale your Amazon EC2 capacity up or down automatically according to conditions you define. With Auto Scaling, you can ensure that the number of Amazon EC2 instances you’re using increases seamlessly during demand spikes to maintain performance, and decreases automatically during demand lulls to minimize costs.

You will need to set up Amazon Auto Scaling Groups Command Line Tools on Windows

Now you will need an Amazon Machine Image (AMI)

What is an Amazon Machine Image (AMI)?

An Amazon Machine Image (AMI) is a special type of pre-configured operating system and virtual application software which is used to create a virtual machine within the Amazon Elastic Compute Cloud (EC2). It serves as the basic unit of deployment for services delivered using EC2.

Let’s imagine you have an AMI: ami-xxxxxx

Before you can create an Auto Scaling Group you need a Launch Configuration

What is a Launch Configuration?

A Launch Configuration defines the AMI to be used, the size of the EC2 instances to be used, the security group the instances will live in and the private key used to decrypt the password in Windows or for gaining access via SSH

You will need to set up Amazon Auto Scaling Groups Command Line Tools on Windows before you can start

How to create a Launch Configuration?
// create launch config
as-create-launch-config my-launch-config-1 --image-id ami-xxxxxx --region eu-west-1 --instance-type m1.small --group my-securitygroup-sg --key myKey
How to check the launch configuration has been created?
// check launch config has been created
as-describe-launch-configs --headers --region eu-west-1  --max-records 50

or check just your launch config has been create

// check your launch config has been created
as-describe-launch-configs my-launch-config-1 --headers --region eu-west-1  --max-records 50
How to delete a launch configuration?
// delete launch config
as-delete-launch-config my-launch-config-1 --region eu-west-1
How to creating an Auto Scaling Group?
// create auto scaling group
as-create-auto-scaling-group my-auto-scaling-group --region eu-west-1 --launch-configuration my-launch-config-1 --availability-zones eu-west-1a eu-west-1b eu-west-1c --min-size 3 --max-size 3 --desired-capacity 3 --default-cooldown 5 --grace-period 5 --tag "k=Name, v=my-server, p=true" --tag "k=enabled, v=true, p=true"
How to check the Auto Scaling Group has been created?
// check auto scaling group has been created
as-describe-auto-scaling-groups --headers --region eu-west-1
How to add or update the Auto Scaling Group tags?

Add or update the Name tag

// add or update the tag
as-create-or-update-tags --tag "id=my-auto-scaling-group, t=auto-scaling-group, k=Name, v=my-server, p=true" --region eu-west-1

Add or update a custom ROLE tag

// add or update the tag
as-create-or-update-tags --tag "id=my-auto-scaling-group, t=auto-scaling-group, k=ROLE, v=production, p=true" --region eu-west-1

Add or update a custom ALLOWED_IPS tag

// add or update tag
as-create-or-update-tags --tag "id=my-auto-scaling-group, t=auto-scaling-group, k=ALLOWED_IPS, v=XXX.XXX.XXX.XXX, p=true" --region eu-west-1
How to scale up the Auto Scaling Group?

This would scale your group of instances up to 6 and set a max of 12

// scale up
as-update-auto-scaling-group my-auto-scaling-group --region eu-west-1 --min-size 6 --max-size 12 --desired-capacity 6
How to scale down the Auto Scaling Group?

This would scale your group of instances up to 3 and set a max of 6

// scale down
as-update-auto-scaling-group my-auto-scaling-group --region eu-west-1 --min-size 3 --max-size 6 --desired-capacity 3
How to set zero instances in the Auto Scaling Group?

This would remove all instances, but keep the auto scaling group configuration ready for use in the future

// with zero instances
as-update-auto-scaling-group my-auto-scaling-group --desired-capacity 0 --max-size 0 --min-size 0 --region eu-west-1
How to delete an Auto Scaling Group?
// delete auto scaling group
as-delete-auto-scaling-group my-auto-scaling-group --region eu-west-1
How to get the Auto Scaling Groups latest activities?

This is handy for trouble shooting problems with your Auto Scaling Group

// to get latest actions
as-describe-scaling-activities --auto-scaling-group my-auto-scaling-group --region eu-west-1

How to update the Auto Scaling Group Configuration

This command lets you change auto scaling group configuration, zones, the min, max and desired number of instances

// with many options
as-update-auto-scaling-group my-auto-scaling-group --launch-configuration my-launch-config-2 --availability-zones eu-west-1a eu-west-1b eu-west-1c --desired-capacity 3 --max-size 3 --min-size 3 --region eu-west-1
How to change the Auto Scaling Group’s Launch Configuration

This will set a new launch configuration for the auto scaling group

// with new launch config
as-update-auto-scaling-group my-auto-scaling-group --launch-configuration my-launch-config-2 --region eu-west-1

Further Reading



Comments

  1. Alex G. August 15th

    Comment Arrow

    Thank you


  2. Pure Garcinia Cambogia October 12th

    Comment Arrow

    Good day! I just want to give you a huge thumbs up for the great info you’ve
    got here on this post. I will be returning to your website
    for more soon.


Add Yours

  • Author Avatar

    YOU


Comment Arrow




About Author

Robert

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning hands down.