Day 40 AWS EC2 Automation

Day 40 AWS EC2 Automation

Amazon EC2 or Amazon Elastic Compute Cloud can give you secure, reliable, high-performance, and cost-effective computing infrastructure to meet demanding business needs.

Also, if you know a few things, you can automate many things.

Launch template in AWS Ec2:

  • You can make a launch template with the configuration information you need to start an instance. You can save launch parameters in launch templates so you don't have to type them in every time you start a new instance.

  • For example, a launch template can have the AMI ID, instance type, and network settings that you usually use to launch instances.

  • You can tell the Amazon EC2 console to use a certain launch template when you start an instance.

Instance Types:

Amazon EC2 has a large number of instance types that are optimised for different uses. The different combinations of CPU, memory, storage and networking capacity in instance types give you the freedom to choose the right mix of resources for your apps. Each instance type comes with one or more instance sizes, so you can adjust your resources to meet the needs of the workload you want to run.

AMI(Amazon Machine Image):

An Amazon Machine Image (AMI) is an image that AWS supports and keeps up to date. It contains the information needed to start an instance. When you launch an instance, you must choose an AMI. When you need multiple instances with the same configuration, you can launch them from a single AMI.

Task 1:

  • Create a launch template with Amazon Linux 2 AMI and t2.micro instance type with Jenkins and Docker setup (You can use the Day 39 User data script for installing the required tools.

    1. Open the amazon Ec2 console.

    2. Click on Launch instance.

    3. Type the name of an instance according to your use.

    4. Choose AMI (Amazon Machine Image).

    5. Then choose instance type.

    6. Then create a key-pair-login or If you already have one then you can select it.

    7. Finally click on Launch instance.

    8. Jenkins setup - Fill the required information.

    9. Jenkins is ready.

    10. Docker setup-

      sudo apt-get update
      sudo apt-get install ca-certificates curl gnupg
      sudo install -m 0755 -d /etc/apt/keyrings
      curl -fsSL | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
      sudo chmod a+r /etc/apt/keyrings/docker.gpg
      echo \
        "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
        $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
        sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
      sudo apt-get update
      sudo apt-get install docker-ce docker-ce-cli docker-buildx-plugin docker-compose-plugin
      sudo docker run hello-worldCreate 3 Instances using Launch Template, there must be an option that shows number of instances to be launched ,can you find it? :)
      • Create 3 Instances using Launch Template, there must be an option that shows number of instances to be launched ,can you find it? :)

        It's very simple just you need to enter number of instnace you want and write the number in Number of instance.

  • You can go one step ahead and create an auto-scaling group?

    An Auto Scaling group contains a collection of EC2 instances that are treated as a logical grouping for the purposes of automatic scaling and management. An Auto Scaling group also lets you use Amazon EC2 Auto Scaling features such as health check replacements and scaling policies.