AWS Classroom Series – 13/Nov/2019

Amazon Machine Image

  • All Virtualizations require some image to start the Virtual Machine
  • Amazon Machine Image is clone of Hard disk with OS and some metadata.
  • Creating Amazon Machine Image:
    • Create an EC2 Instance
    • Configure EC2 instance with necessary software/configurations
    • Create an EC2 Image
  • Amazon Machine Image will have Storage Costs.
  • Automated way of Creating AMIs
    • using AWS CLI
    • Using Packer
  • AMI will be create in only one Region. If you want a multi region AMI, Create AMI and copy across other regions(AMI id changes). Each Region has a unique AMI

CLI TO Create AWS Ec2 AMI

  • Create an IAM User with EC2 full access and Programmatic Access
  • Install AWS CLI Refer Here and Configure the user using
aws configure
  • Create an Ec2 machine.
aws ec2 run-instances --count 1 --image-id ami-06d51e91cea0dac8d --instance-type t2.micro --key-name ec2learnings --security-group-ids sg-00d319006f01acfd5 --subnet-id subnet-030f585b
  • After Launching an Ec2 machine, install apache2
sudo apt-get update
sudo apt-get install apache2 -y
  • Create an AMI by executing the following CLI command
aws ec2 create-image --instance-id <instance id> --name my-apache-1
# make  a note of AMI id
  • Execute describe AMI till the status is Available
aws ec2 describe-image --image-id <image-idfromabovecommand>
  • Now launch the Ec2 machine with your image
aws ec2 run-instances --count 1 --image-id <my-apache-1-id> --instance-type t2.micro --key-name ec2learnings --security-group-ids sg-00d319006f01acfd5 --subnet-id subnet-030f585b
  • Now login into the machine and check the machine for the contents/configurations, they will match.

Exercise: Create an Amazon Machine Image

  • Create a ubuntu machine
  • Login into the machine and install lamp stack. Refer Here
  • Manual Steps
sudo apt-get update
sudo apt-get install apache2 -y
sudo apt-get install php libapache2-mod-php php-mysql php-cli -y
# Create a file at /var/www/html/info.php
sudo nano /var/www/html/info.php

# Contents
<?php
phpinfo();
?>

sudo apt-get install stress -y

Scaling

  • Vertical Scaling:
    • Increasing the hardware resource configuration.
    • Downtime will be required
  • Horizontal Scaling
    • Increase VMs or Servers
    • Doesn’t require a downtime for existing server

Scaling vs Elasticity

  • Scaling is all about increasing
  • Elasticity is about increasing and decreasing as well
  • In AWS we use Elasticity.
  • Vertical Scaling Can be achieved by using Change Instance Type after shutdown of Ec2 instance (Stopped)
  • Horizontal Scaling is achieved by Auto Scaling Groups

Leave a Reply

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

About continuous learner

devops & cloud enthusiastic learner