• Devops Diaries
  • Posts
  • [AWS Hands-on]- Launch, Secure, and Scale EC2 Instances

[AWS Hands-on]- Launch, Secure, and Scale EC2 Instances

Hands-on AWS content is highly valuable for practical learning. As part of AWS Hands-on Topics covering all major AWS services. Today as this is our first hands-on,so starting with Launching of EC2 instance.

Hands-on AWS content is highly valuable for practical learning. As part of AWS Hands-on Topics covering all major AWS services, today will start with …

Launch, Secure, and Scale EC2 Instances

Task: Launch an EC2 Instance

Step 1: Login to AWS Console

Step 2: Launch an EC2 Instance

  • Click "Launch Instance".

  • Choose an Amazon Machine Image (AMI) (e.g., Amazon Linux 2, Ubuntu, or Windows).

  • Select an Instance Type (e.g., t2.micro for free tier).

  • Configure instance details:

    • Set the number of instances.

    • Choose a VPC and subnet (default or custom).

    • Enable Auto-Assign Public IP (if needed).

  • Add Storage (default is 8GB for Amazon Linux, increase as needed).

  • Add Tags (Key: Name, Value: MyEC2Instance).

  • Configure a Security Group (firewall rules).

    • Allow SSH (port 22) for your IP (My IP option).

    • Allow HTTP (port 80) if running a web server.

  • Review and click Launch.

  • Select or create a Key Pair (for SSH access), download it, and launch the instance.

Step 3: Connect to the Instance

  • Once the instance is running, go to Instances → Select Instance → Connect.

  • Copy the SSH command and connect via terminal:

ssh -i my-key.pem ec2-user@your-ec2-public-ip

Task: Secure the EC2 Instance

Step 1: Update and Install Security Patches

sudo yum update -y # For Amazon Linux

sudo apt update && sudo apt upgrade -y # For Ubuntu

Step 2: Set Up a Firewall (Using UFW on Ubuntu)

sudo ufw allow OpenSSH

sudo ufw enable

sudo ufw status

Step 3: Disable Root Login and Password Authentication

Edit the SSH config: sudo vi /etc/ssh/sshd_config

  • Set PermitRootLogin no

  • Set PasswordAuthentication no Restart SSH:

sudo systemctl restart sshd

Step 4: Enable AWS IAM Role for Access Control

  • Create an IAM Role with AmazonSSMManagedInstanceCore permissions.

  • Attach it to your EC2 instance.

  • Use AWS Systems Manager for remote access instead of SSH.

Task : Scale EC2 Instances (Auto Scaling)

Step 1: Create a Load Balancer

  • Go to EC2 → Load Balancers.

  • Click Create Load Balancer (choose Application Load Balancer).

  • Assign security groups, target groups, and listeners (HTTP/HTTPS).

Step 2: Create an Auto Scaling Group

  • Go to EC2 → Auto Scaling Groups.

  • Click Create Auto Scaling Group.

  • Select the EC2 Launch Template.

  • Set the desired, minimum, and maximum instance count.

  • Attach to a Load Balancer.

  • Configure Scaling Policies (CPU utilization, request count, etc.).

Reply

or to participate.