DevOps, Day - 40

Automation in EC2

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.

Read from here

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.

Read more here

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.

Read from here

AMI

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.


Create a Launch Template with Ubuntu AMI

  1. Open the AWS Management Console.

  2. Navigate to the EC2 service.

  3. In the EC2 Dashboard, click on "Launch Templates" in the left sidebar.

  4. Click the "Create launch template" button.

  5. In the "Create launch template" wizard:

    • Provide a name for your launch template (e.g., "Jenkins-Docker-Template").

    • In the "AMI ID" field, select an Ubuntu AMI that matches your desired Ubuntu version and region.

    • In the "Instance type" field, select "t2.micro."

    • Scroll down to the "Advanced details" section and provide the User Data script to install Jenkins and Docker on Ubuntu. You can adapt the script for Ubuntu.

        #!/bin/bash
        sudo apt update
        sudo apt install -y docker.io
        sudo systemctl start docker
        sudo systemctl enable docker
        sudo apt install -y openjdk-11-jdk
        wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
        sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
        sudo apt update
        sudo apt install -y jenkins
        sudo systemctl start jenkins
      
  6. Click "Create launch template."

  7. Our Launch Template is created.


Create 3 Instances Using Launch Template

  1. In the EC2 Dashboard, click "Instances" in the left sidebar.

  2. Click the arrow beside the "Launch instances" button, and select "Launch instances from template"

  3. In the "Launch instances from template" wizard, select the launch template you created with Ubuntu AMI.

  4. You will see an option under "Summary Section" called "Number of instances." Here, you can specify the number of instances you want to launch. Enter "3" for the number of instances. And click on "Launch instance"

  5. Here are the 3 running instances.


Create an Auto-Scaling Group

  1. In the EC2 Dashboard, click "Auto Scaling Groups" in the left sidebar.

  2. In the "Create Auto Scaling group" wizard

    • Select the launch template you created earlier with the Ubuntu AMI.

    • Configure other settings like the desired and maximum capacity, network settings, scaling policies, and tags. and Click on "Create auto-scaling group"

  3. Our group is created

    Don't Forget to Stop the instances :)


Thank you so much for reading

Follow me on LinkedIn to see interesting posts like this : )

Linkedin

0
Subscribe to my newsletter

Read articles from Vrishni Shree V B directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Vrishni Shree V B
Vrishni Shree V B

๐Ÿ’ป Python | Docker | Jenkins | Networking | Git | Linux ๐Ÿ’ป Passionate about leveraging technology to drive efficiency and deliver innovative solutions. Proficient in Python development, Docker containerization, Jenkins automation, computer networking, Git version control, and Linux administration. Skilled in collaborating with diverse teams to deliver high-quality software products. Proficient in AWS EC2 instance management and deployment. Seeking new opportunities to apply my expertise and contribute to impactful projects. Let's connect and explore how we can work together! Inter-personal Skills: Communication, Adaptability, Emotional intelligence, Active listening, Collaboration. Happy To Connect๐Ÿ”—๐Ÿ˜Š Feel free to reach me out๐Ÿ˜ƒ@ --> vrishnishreevb531@gmail.com ๐Ÿ“ฌ