Posts

Showing posts from March, 2026

AWS: Highly available infrastructure using ASG and ELB

Building a Highly Available Environment on AWS using Auto Scaling Group and Load Balancer 1. Introduction Highly available infrastructure ensures that applications remain accessible even if one or more servers fail. In AWS, this can be achieved by combining: - EC2 Instances - Auto Scaling Group (ASG) - Elastic Load Balancer (ELB) - Health Checks This architecture automatically replaces unhealthy instances and distributes traffic across multiple servers. --- 2. Prerequisites Before starting the setup, ensure the following components are available. 2.1 AWS Account You must have access to the AWS Management Console. 2.2 VPC Setup A Virtual Private Cloud with: - At least two public subnets - Subnets in different Availability Zones Example: VPC ├── Subnet-A (Availability Zone 1) └── Subnet-B (Availability Zone 2) 2.3 Security Group Allow the following ports: HTTP (80) HTTPS (443) SSH (22) --- 3. Launch Base EC2 Instance First create a base EC2 instance which will la...

AWS: Monitor EC2 instance with cloudwatch alarms and email alerts

Step-by-Step Guide: Setup CloudWatch Agent on Linux EC2 with Alerts and SNS Notifications 1. Prerequisites Before starting the setup, ensure the following requirements are met. 1.1 EC2 Linux Instance You must have a running Linux EC2 instance. Supported operating systems include: - Amazon Linux - RHEL / Rocky Linux / CentOS - Ubuntu Example configuration: OS: Amazon Linux / RHEL / Ubuntu Instance type: t2.micro or above Internet access: Required 1.2 AWS Permissions The EC2 instance must have permission to push metrics and logs to CloudWatch. This is done using an IAM role. --- 2. Create IAM Role for CloudWatch Agent 1. Go to AWS Console 2. Open IAM 3. Click Roles 4. Click Create Role Select Trusted Entity Trusted entity: AWS Service Use case: EC2 Attach Permission Policy Attach the following policy: CloudWatchAgentServerPolicy Role Name EC2-CloudWatch-Agent-Role Create the role. --- 3. Attach IAM Role to EC2 Instance 1. Go to EC2 Dashboard 2. Select your EC2 in...