AWS Classroom Series – 20/Aug/2020


  • Create an IAM user with necessary permissions to create ec2 instances and auto scaling groups and configure the user credentials
aws configure
  • Now lets create a vm with ubuntu instance
  • Get the image id
# Get the image ami information
aws ec2 describe-images --filters "Name=description,Values=Canonical*" "Name=architecture,Values=x86_64"

# Ami id : ami-0a634ae95e11c6f91

* Lets find a security group id

aws ec2 describe-security-groups

aws ec2 describe-key-pair
  • Now create ec2 instance with image id ami-0a634ae95e11c6f91
aws ec2 run-instances --image-id "ami-0a634ae95e11c6f91" --instance-type "t2.micro" --key-name "terraform" --security-group-ids sg-001ad9d463119ad7a --count 1 --associate-public-ip-address
  • Now wait for the machine to be in running state
aws ec2 describe-instances --instance-id i-012bc2a0a5a739dc1
  • Now lets build ssh command
ssh -i terraform.pem ubuntu@
  • Now install lamp and stress
sudo apt-get update
sudo apt-get install apache2 php libapache2-mod-php php-cli php-mysql stress -y
sudo -i
echo "<?php phpinfo(); ?>" > /var/www/html/info.php
  • Now lets create ami for the ec2 instance
aws ec2 create-image --instance-id i-012bc2a0a5a739dc1 --name lampwithstress
  • The image id is ami-0000e3e8be0ce2112 in this case.
  • Now lets create a autoscaling group which requires launch configuration/template. So lets create launch configuration
aws autoscaling create-launch-configuration --launch-configuration-name 'fromcli' --image-id ami-0000e3e8be0ce2112 --key-name terraform --security-groups sg-001ad9d463119ad7a --instance-type "t2.micro"

 aws autoscaling describe-launch-configurations
  • Lets get subnet ids
aws ec2 describe-subnets --filters "Name=availability-zone,Values=us-west-2a,us-west-2b"

# subnets
  • Now lets create autoscaling group
aws autoscaling create-auto-scaling-group --auto-scaling-group-name "asgfromcli" --launch-configuration-name "fromcli" --min-size 1 --max-size 5 --vpc-zone-identifier "subnet-80ed0eca,subnet-3e529446"
  • Lets describe the autoscaling groups
aws autoscaling describe-auto-scaling-groups
  • Now create a load balancer by referring from here
  • Pending parts for exercise:
    • Create an aws application load balancer
    • Test with stress tool
    • Delete everything which you have created

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About learningthoughtsadmin