AWS Projects
AWS Projects
Project 4: Scalable Web App with ALB & Auto Scaling – Use EC2, ALB, and
Auto Scaling for high availability.
Project 5: Scalable Web App with NLB & Auto Scaling – Use EC2, ALB, and
Auto Scaling for high availability.
Project 6: Serverless API with Lambda & API Gateway – Build a RESTful API
using Lambda.
Project 8: Serverless Chatbot – Build an AI-powered chatbot with AWS Lex &
Lambda.
Project 11: Serverless Expense Tracker – Use Lambda, DynamoDB, and API
Gateway to build an expense management app.
Project 13: Real-time Polling App – Use WebSockets with API Gateway and
DynamoDB for a real-time polling system.
Project 1: Terraform for AWS – Deploy VPC, EC2, and RDS using Terraform.
Project 2: CloudFormation for Infrastructure as Code – Automate AWS
resource provisioning.
Project 3: AWS CDK Deployment – Use AWS Cloud Development Kit (CDK) to
manage cloud infrastructure.
Project 4: Automate AWS Resource Tagging – Use AWS Lambda and Config
Rules for enforcing tagging policies.
Project 6: Automated Cost Optimization – Use AWS Lambda to detect and stop
unused EC2 instances.
Project 9: Automated EC2 Scaling Based on Load – Use Auto Scaling policies
with CloudWatch to optimize cost and performance.
Project 1: IAM Role & Policy Management – Secure AWS resources using IAM
policies.
Project 4: AWS Security Hub & GuardDuty – Monitor security threats and
enforce compliance.
Project 5: Automated Compliance Auditing – Use AWS Config to check
security best practices.
Project 8: AWS WAF for Application Security – Protect a web application from
SQL injection and XSS attacks using AWS WAF.
5. CI/CD Projects:
6. DevOps Projects:
Project 3: Data Warehouse with AWS Redshift – Store and analyze structured
data in Redshift.
Project 4: ETL with AWS Glue – Transform data from S3 to Redshift using AWS
Glue.
Project 1: Monitor AWS Resources with CloudWatch & SNS – Set up alerts for
EC2, RDS, and S3.
Project 2: Log Analysis with ELK Stack – Deploy Elasticsearch, Logstash, and
Kibana on AWS.
Project 4: Query S3 Logs with AWS Athena – Analyze stored logs without
setting up a database.
Project 1: Route 53 DNS Management – Configure and manage DNS records for
custom domains.
Project 4: Hybrid Cloud Setup with AWS VPN – Connect an on-premises data
center to AWS.
Project 1: Big Data Processing with AWS EMR – Use Apache Spark to analyze
large datasets.
Project 4: AWS Athena for Log Analysis – Query CloudTrail and VPC Flow
Logs using Athena.
Project 1: Train & Deploy ML Models with SageMaker – Use AWS SageMaker
for predictive analytics.
Project 4: IoT Data Processing with AWS IoT Core – Store and analyze IoT
sensor data in AWS.
Project 2: AWS Backup for EBS Snapshots & Recovery – Automate backups
and restore EC2 instances.
Project 3: Automated AMI Creation & Cleanup – Schedule AMI snapshots and
delete old backups.
Static Website Hosting using S3, Route 53 & CloudFront – Complete Steps
Hosting a static website on Amazon S3, integrating it with Route 53 for domain
name resolution, and using CloudFront for content delivery enhances
performance, security, and reliability.
Prerequisites:
✅ An AWS account
✅ A registered domain (either in Route 53 or another provider)
Step 1: Create an S3 Bucket for Website Hosting
Under Bucket Policy, click Edit and paste the following JSON policy:
json
{
"Version": "2012-10-17",
"Statement": [
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::example.com/*"
● Select the region closest to your target audience for better performance.
● Go to the Networking tab and create a Static IP to prevent your site from
changing its IP on reboot.
● Attach the static IP to your instance.
Install a free SSL certificate using Let’s Encrypt with the following
commands:
sudo /opt/bitnami/bncert-tool
Final Thoughts
In this project, you will deploy a web server using Amazon EC2. You will launch
an EC2 instance, install either Apache or Nginx, and configure it to serve a basic
website.
Install Apache:
sudo yum install httpd -y # Amazon Linux
For Nginx
Install Nginx:
sudo yum install nginx -y # Amazon Linux
Verify installation:
sudo systemctl status nginx
(For Ubuntu, this step is not needed if using a security group in AWS)
Conclusion
Project 4: Scalable Web App with ALB & Auto Scaling – Use EC2, ALB, and
Auto Scaling for high availability.
This project involves deploying a highly available web application using Amazon
EC2, Application Load Balancer (ALB), and Auto Scaling. The goal is to
ensure that the web app can scale automatically based on traffic demand while
maintaining availability.
○ Security Group: Allow SSH (22), HTTP (80), and HTTPS (443).
Run:
ab -n 1000 -c 50 http://your-alb-dns-name/
✅
✅
This setup ensures: High Availability using ALB
✅
Scalability using Auto Scaling
Redundancy across multiple AZs
Project 5: Scalable Web App with NLB & Auto Scaling – Use EC2, ALB, and
Auto Scaling for high availability.
Overview:
In this project, we will deploy a scalable and highly available web application
using EC2 instances, Network Load Balancer (NLB), and Auto Scaling. This
setup ensures that our web application can handle varying traffic loads efficiently
while maintaining availability and reliability.
● Launch multiple EC2 instances with a web server installed (e.g., Apache,
Nginx, or a custom application).
● Configure the security group to allow HTTP (port 80) and necessary ports
for application communication.
● Ensure the web server is properly configured to serve requests.
● Obtain the NLB DNS name and test the application in a browser.
● Simulate traffic using Apache Benchmark (ab) or Siege to verify Auto
Scaling behavior.
● Monitor the Auto Scaling Group to ensure new instances launch and
terminate as needed.
● ALB Security Group → Allow HTTP (80) and HTTPS (443) from the
internet.
● Web/App EC2 Security Group → Allow HTTP (80) only from the ALB.
● Database Security Group → Allow MySQL/PostgreSQL (3306) only from
the Web/App layer.
cd <your-app>
Conclusion
This setup provides a scalable, highly available, and secure multi-tier web
application architecture on AWS. It ensures redundancy using ALB, Auto Scaling,
and RDS Multi-AZ, making it resilient to failures.
A serverless static website on AWS eliminates the need for traditional web servers
by using Amazon S3 for hosting static content, CloudFront for global content
delivery, and Lambda@Edge for dynamic content processing. This setup provides
high availability, low latency, and cost efficiency.
"Version": "2012-10-17",
"Statement": [
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::your-bucket-name/*"
If you need to modify responses dynamically (e.g., adding security headers, URL
rewrites), create a Lambda@Edge function.
return response;
};
Conclusion
With this setup, your static website is hosted on S3, served globally using
CloudFront, and can be enhanced with Lambda@Edge for additional processing.
This architecture ensures scalability, security, and cost efficiency.
listTasks {
id
title
description
status
}
Step 6: Secure the API (Optional)
Conclusion
You have successfully deployed a GraphQL API using AWS AppSync and
DynamoDB. This setup allows seamless CRUD operations with real-time updates,
making it an efficient backend solution for modern applications.
Introduction
A Progressive Web App (PWA) combines the best of web and mobile applications
by offering fast load times, offline support, and a native-like experience. AWS
Amplify provides an easy way to deploy and host PWAs built with React or Vue.js,
with automatic CI/CD integration.
Step 1: Prerequisites
● AWS account
● Node.js installed (check with node -v)
● GitHub, GitLab, or Bitbucket repository with a React or Vue.js PWA
Step 2: Create a React or Vue.js PWA (Optional)
For React:
sh
cd my-pwa
npm start
For Vue.js:
sh
cd my-pwa
npm install
sh
git init
git add .
Conclusion
You have successfully deployed a React or Vue.js PWA on AWS Amplify! This
setup ensures seamless CI/CD, HTTPS, and scalability for your PWA
Project 4: Jamstack Site with AWS – Use AWS Amplify, Headless CMS, and S3
for a Jamstack website.
Build a modern, fast, and scalable Jamstack website using AWS Amplify, a
Headless CMS, and S3 for static hosting. This approach decouples the frontend
from the backend, improving performance, security, and scalability.
1. Fetch data from the CMS using REST or GraphQL APIs.
2. Display dynamic content on your website using API calls.
This project helps create a fast, secure, and scalable Jamstack website using AWS
services. With AWS Amplify for deployment, a Headless CMS for content
management, and S3 for storage, you ensure a seamless user experience
Introduction:
Complete Steps:
Step 1: Prerequisites
● AWS Account
● Docker installed on your local machine
● AWS CLI configured
● A containerized web application (e.g., a simple Node.js or Python Flask app)
COPY . .
EXPOSE 8080
2.
3.
1.
2.
3.
4.
● Use AWS App Runner logs and metrics to monitor your service.
● Update your image in ECR and redeploy for changes.
Conclusion
AWS App Runner makes it easy to deploy and scale containerized applications
without managing infrastructure. It’s ideal for developers who want a serverless
experience for their web apps.
Project 6: Serverless API with Lambda & API Gateway – Build a RESTful API
using Lambda.
This project involves building a RESTful API using AWS Lambda and API
Gateway. It eliminates the need for managing servers, providing a scalable and
cost-effective solution. Lambda handles the backend logic, while API Gateway
routes requests and manages security.
return {
"statusCode": 200,
●
● Click Deploy.
●
●
Enhancements (Optional)
Introduction
● Click Create API → Choose "Build from scratch" → Enter API name →
Select "Create".
● Choose GraphQL as the API type.
id: ID!
title: String!
completed: Boolean!
type Query {
getTodos: [Todo]
}
type Mutation {
deleteTodo(id: ID!): ID
schema {
query: Query
mutation: Mutation
●
"version": "2018-05-29",
"operation": "PutItem",
"key": {
},
"attributeValues": {
●
id
title
completed
●
getTodos {
id
title
completed
●
This project provides hands-on experience with AWS AppSync, GraphQL, and
DynamoDB, enabling you to build a serverless GraphQL backend efficiently. You
can extend it by adding authentication, subscriptions for real-time updates, and
integrating a frontend.
Project 8: Serverless Chatbot – Build an AI-powered chatbot with AWS Lex &
Lambda.
Introduction
A serverless chatbot allows users to interact using natural language. AWS Lex
provides automatic speech recognition (ASR) and natural language understanding
(NLU) to process user queries. AWS Lambda processes user inputs and responds
dynamically. This chatbot can be integrated into applications like websites or
messaging platforms.
Conclusion
This project demonstrates how to build a serverless AI chatbot using AWS Lex and
Lambda. It provides an interactive experience for users and can be customized for
various use cases like customer support, FAQs, or order tracking.
Introduction
python
import boto3
import json
message = {
"order_id": "12345",
"status": "created"
response = sns.publish(
TopicArn=topic_arn,
Message=json.dumps(message),
The consumer microservice will process messages from the SQS queue.
python
import boto3
sqs = boto3.client('sqs', region_name='us-east-1')
queue_url =
'https://sqs.us-east-1.amazonaws.com/123456789012/order-processing-queue'
def process_messages():
while True:
messages = sqs.receive_message(
QueueUrl=queue_url,
MaxNumberOfMessages=1,
WaitTimeSeconds=10
if 'Messages' in messages:
sqs.delete_message(QueueUrl=queue_url,
ReceiptHandle=msg['ReceiptHandle'])
process_messages()
Conclusion
Creating a serverless URL shortener using AWS services like Lambda and
DynamoDB enables efficient and scalable management of URL mappings without
the need to manage underlying server infrastructure. This approach leverages
AWS's fully managed services to handle the backend operations seamlessly.
Step-by-Step Implementation:
Implement the function to handle both the creation of short URLs and the
redirection logic.
Sample Code:
python
import json
import boto3
import string
import random
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('URLShortener')
def generate_short_code():
http_method = event['httpMethod']
if http_method == 'POST':
body = json.loads(event['body'])
long_url = body['long_url']
short_code = generate_short_code()
table.put_item(Item={
'short_code': short_code,
'long_url': long_url
})
return {
'statusCode': 200,
params = event['queryStringParameters']
short_code = params['short_code']
if 'Item' in response:
long_url = response['Item']['long_url']
return {
'statusCode': 301,
else:
return {
'statusCode': 404,
By following these steps, you can create a scalable and cost-effective URL
shortening service using AWS's serverless architecture.
Project 11: Serverless Expense Tracker – Use Lambda, DynamoDB, and API
Gateway to build an expense management app.
Set Execution Role: Create a new role with DynamoDB Full Access.
import json
import boto3
import uuid
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('Expenses')
expense_id = str(uuid.uuid4())
expense_id = event['queryStringParameters']['expense_id']
data = json.loads(event['body'])
expense_id = data['expense_id']
table.update_item(
Key={"expense_id": expense_id},
expense_id = event['queryStringParameters']['expense_id']
table.delete_item(Key={"expense_id": expense_id})
Define endpoints:
-H "Content-Type: application/json" \
7. Frontend (Optional)
Conclusion
Overview:
When an image is uploaded to a designated S3 bucket, it triggers a Lambda
function. This function processes the image—resizing it as specified—and then
stores the resized image back into an S3 bucket.
Steps to Implement:
Write the function code to handle image processing. For instance, using
Node.js with the 'jimp' library:
javascript
const AWS = require('aws-sdk');
try {
const destParams = {
Bucket: DEST_BUCKET,
Key: objectKey,
Body: resizedImage,
ContentType: 'image/jpeg'
};
// Upload the resized image to the destination bucket
await s3.putObject(destParams).promise();
} catch (error) {
throw error;
};
○ In this script, the Lambda function retrieves the uploaded image from
the source S3 bucket, resizes it to 200x200 pixels using the 'jimp'
library, and uploads the resized image to the destination S3 bucket.
4. Package and Deploy the Lambda Function:
○ Install necessary dependencies locally and package them with your
Lambda function code into a ZIP file.
○ Upload this ZIP file to AWS Lambda.
5. Configure Environment Variables:
○ Set environment variables in the Lambda function configuration, such
as DEST_BUCKET, to specify the destination S3 bucket for resized
images.
6. Set Up S3 Event Trigger:
○ Configure the source S3 bucket to trigger the Lambda function upon
object creation events (e.g., when a new image is uploaded).
7. Test the Setup:
○ Upload an image to the source S3 bucket.
○ Verify that the Lambda function executes successfully and that the
resized image appears in the destination S3 bucket.
By following these steps, you can establish a serverless architecture that
automatically resizes images upon upload, optimizing storage and ensuring
consistent image dimensions across your applications.
Project 13: Real-time Polling App – Use WebSockets with API Gateway and
DynamoDB for a real-time polling system.
Introduction
This project involves building a real-time polling system using AWS WebSockets
with API Gateway and DynamoDB. It allows users to vote on polls and see
real-time updates without refreshing the page. WebSockets enable full-duplex
communication between clients and the backend, making it ideal for live updates.
This project demonstrates how to build a real-time polling app using WebSockets
in API Gateway, Lambda, and DynamoDB. It ensures instant updates for users and
scales efficiently on AWS.
Introduction
import boto3
import json
import requests
# AWS Clients
comprehend = boto3.client('comprehend')
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('SentimentAnalysis')
Conclusion
This serverless solution efficiently analyzes tweets using AWS Comprehend and
stores the results in DynamoDB. It eliminates infrastructure management and
provides a scalable approach to sentiment analysis.
Project 1: Terraform for AWS – Deploy VPC, EC2, and RDS using Terraform.
1. Prerequisites:
Create a new directory for your Terraform project and navigate into it:
mkdir terraform-aws-project
cd terraform-aws-project
3. Initialize Terraform:
Initialize the Terraform project to download necessary providers:
terraform init
4. Create a VPC:
hcl
provider "aws" {
cidr_block = "10.0.0.0/16"
tags = {
Name = "main_vpc"
5. Create Subnets:
hcl
cidr_block = "10.0.1.0/24"
availability_zone = "us-west-2a"
tags = {
Name = "public_subnet"
vpc_id = aws_vpc.main_vpc.id
cidr_block = "10.0.2.0/24"
availability_zone = "us-west-2a"
tags = {
Name = "private_subnet"
hcl
resource "aws_internet_gateway" "igw" {
vpc_id = aws_vpc.main_vpc.id
tags = {
Name = "main_igw"
vpc_id = aws_vpc.main_vpc.id
route {
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.igw.id
tags = {
Name = "public_route_table"
subnet_id = aws_subnet.public_subnet.id
route_table_id = aws_route_table.public_route_table.id
}
Define security groups for the EC2 instance and RDS database:
hcl
vpc_id = aws_vpc.main_vpc.id
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
egress {
from_port = 0
to_port =0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
tags = {
Name = "ec2_sg"
}
vpc_id = aws_vpc.main_vpc.id
ingress {
to_port = 3306
protocol = "tcp"
egress {
from_port = 0
to_port =0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
tags = {
Name = "rds_sg"
}
8. Launch an EC2 Instance:
hcl
instance_type = "t2.micro"
subnet_id = aws_subnet.public_subnet.id
security_groups = [aws_security_group.ec2_sg.name]
tags = {
Name = "web_server"
hcl
name = "rds_subnet_group"
subnet_ids = [aws_subnet.private_subnet.id]
tags = {
Name = "rds_subnet_group"
allocated_storage = 20
engine = "mysql"
engine_version = "8.0"
instance_class = "db.t2.micro"
name = "mydatabase"
username = "admin"
db_subnet_group_name = aws_db_subnet_group.rds_subnet_group.name
vpc_security_group_ids = [aws_security_group.rds_sg.id]
skip_final_snapshot = true
tags = {
Name = "rds_instance"
}
**10. Apply the Terraform Configuration:
Introduction
This project will guide you through creating a CloudFormation stack to deploy a
Virtual Private Cloud (VPC), an EC2 instance, and an RDS database.
1. Prerequisites
yaml
AWSTemplateFormatVersion: '2010-09-09'
Resources:
MyVPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 10.0.0.0/16
EnableDnsSupport: true
EnableDnsHostnames: true
MySubnet:
Type: AWS::EC2::Subnet
Properties:
CidrBlock: 10.0.1.0/24
MySecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Allow SSH and HTTP
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 22
ToPort: 22
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: 80
ToPort: 80
CidrIp: 0.0.0.0/0
MyEC2Instance:
Type: AWS::EC2::Instance
Properties:
InstanceType: t2.micro
SecurityGroupIds:
- !Ref MySecurityGroup
Tags:
- Key: Name
Value: CloudFormationInstance
MyRDSInstance:
Type: AWS::RDS::DBInstance
Properties:
DBInstanceIdentifier: mydatabase
Engine: mysql
MasterUsername: admin
MasterUserPassword: Password123
AllocatedStorage: 20
DBInstanceClass: db.t2.micro
PubliclyAccessible: true
Use AWS CLI or the AWS Management Console to deploy the stack.
sh
🚀
infrastructure provisioning. By defining resources in a YAML/JSON template, you
can consistently deploy and manage AWS services efficiently.
Project 3: AWS CDK Deployment – Use AWS Cloud Development Kit (CDK) to
manage cloud infrastructure.
AWS CDK Project: Deploying S3, Lambda, API Gateway, and RDS
✅
This updated CDK stack will:
✅
Create an S3 Bucket for file storage
✅
Deploy an AWS Lambda Function to process requests
✅
Set up API Gateway to expose the Lambda function as an HTTP endpoint
Deploy an Amazon RDS (PostgreSQL) instance for database storage
Inside your AWS CDK project directory, install the required AWS CDK
libraries:
Edit the lib/my-cdk-app-stack.ts file and replace its content with the
following:
typescript
import * as cdk from 'aws-cdk-lib';
// Create an S3 Bucket
versioned: true,
removalPolicy: cdk.RemovalPolicy.DESTROY
});
});
// Create an RDS PostgreSQL database
engine: rds.DatabaseInstanceEngine.postgres({
version: rds.PostgresEngineVersion.VER_13,
}),
vpc,
allocatedStorage: 20,
instanceType: ec2.InstanceType.of(ec2.InstanceClass.T3,
ec2.InstanceSize.MICRO),
multiAz: false,
publiclyAccessible: false,
removalPolicy: cdk.RemovalPolicy.DESTROY
});
runtime: lambda.Runtime.NODEJS_18_X,
environment: {
BUCKET_NAME: myBucket.bucketName,
DB_ENDPOINT: database.dbInstanceEndpointAddress
});
myBucket.grantReadWrite(myLambda);
database.grantConnect(myLambda);
handler: myLambda,
proxy: true
});
value: api.url
});
Create a new directory named lambda/ inside your CDK project and add a
file called index.js with the following content:
javascript
const response = {
statusCode: 200,
};
return response;
};
cdk bootstrap
cdk synth
cdk deploy
cdk destroy
Conclusion
You have now successfully deployed a complete AWS infrastructure using AWS
CDK, including:
✅ An S3 bucket for storage
✅ A Lambda function for processing requests
✅ An API Gateway for exposing APIs
✅ An RDS PostgreSQL database for persistence
Project 4: Automate AWS Resource Tagging – Use AWS Lambda and Config
Rules for enforcing tagging policies.
Automate AWS Resource Tagging using AWS Lambda and AWS Config Rules
Introduction
Tagging AWS resources is essential for cost allocation, security, and operational
efficiency. However, ensuring consistent tagging across all resources can be
challenging. AWS Lambda and AWS Config Rules can be used to automate the
enforcement of tagging policies, ensuring that all resources comply with the
organization's standards.
How it works:
● AWS Config monitors AWS resources and checks for compliance with
predefined tagging policies.
● AWS Lambda automatically applies missing tags or alerts administrators
when non-compliant resources are found.
Steps to Implement
1. Prerequisites
AWS Config continuously monitors AWS resources and checks for compliance
with a tagging policy.
import boto3
required_tags = {
"Environment": "Production",
"Owner": "DevOps"
def tag_resource(resource_arn):
client = boto3.client('resourcegroupstaggingapi')
response = client.get_resources(ResourceARNList=[resource_arn])
if missing_tags:
client.tag_resources(ResourceARNList=[resource_arn], Tags=missing_tags)
resource_arn = event['detail']['configurationItem']['arn']
tag_resource(resource_arn)
Conclusion
Introduction
AWS Systems Manager (SSM) allows you to automate patch management for EC2
instances, ensuring they are always up-to-date with the latest security updates and
patches. This project sets up AWS Systems Manager Patch Manager to automate
OS patching on EC2 instances using Patch Baselines, Maintenance Windows, and
Automation Documents.
Ensure SSM Agent is installed and running (Amazon Linux 2 and Windows
have it pre-installed).
sudo systemctl status amazon-ssm-agent # For Amazon Linux
Conclusion
This setup ensures EC2 instances are automatically patched based on a defined
schedule and patch policies. AWS Systems Manager provides detailed logs and
reports to track compliance and patching progress.
Project 6: Automated Cost Optimization – Use AWS Lambda to detect and stop
unused EC2 instances.
Introduction
AWS Lambda can be used to detect and stop unused EC2 instances to optimize
cloud costs. By leveraging AWS services like CloudWatch, Lambda, and AWS
SDK (Boto3), we can automate the process of monitoring EC2 instance usage and
shutting down idle instances. This project helps reduce unnecessary cloud expenses
by identifying instances with low CPU utilization over a defined period.
1. Prerequisites
● AWS account with necessary IAM permissions
● Amazon EC2 instances running
● AWS CloudWatch enabled for EC2 instances
● AWS Lambda function with execution role
import boto3
ec2 = boto3.client('ec2')
cloudwatch = boto3.client('cloudwatch')
instance_id = instance['InstanceId']
metrics = cloudwatch.get_metric_statistics(
Period=3600,
StartTime=datetime.utcnow() - timedelta(hours=1),
EndTime=datetime.utcnow(),
MetricName='CPUUtilization',
Namespace='AWS/EC2',
Statistics=['Average'],
if metrics['Datapoints']:
avg_cpu = metrics['Datapoints'][0]['Average']
ec2.stop_instances(InstanceIds=[instance_id])
Conclusion
Introduction:
Self-healing infrastructure ensures high availability and resilience by automatically
recovering from failures. In AWS, this can be achieved using EC2 instances with
Auto Scaling Groups (ASG) and Load Balancers. Terraform helps automate the
provisioning and management of this infrastructure.
Steps to Implement
● Terraform
● AWS CLI (configured with IAM credentials)
● SSH key pair for EC2 access
hcl
provider "aws" {
region = "us-east-1"
hcl
cidr_block = "10.0.0.0/16"
cidr_block = "10.0.1.0/24"
map_public_ip_on_launch = true
hcl
vpc_id = aws_vpc.main_vpc.id
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
egress {
from_port = 0
to_port =0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
hcl
name = "app-template"
instance_type = "t2.micro"
network_interfaces {
associate_public_ip_address = true
security_groups = [aws_security_group.web_sg.id]
user_data = base64encode(<<-EOF
#!/bin/
EOF
)
hcl
vpc_zone_identifier = [aws_subnet.public_subnet.id]
desired_capacity = 2
max_size =3
min_size =1
launch_template {
id = aws_launch_template.app_template.id
version = "$Latest"
health_check_type = "EC2"
health_check_grace_period = 300
}
6. Attach a Load Balancer (load_balancer.tf)
hcl
name = "app-load-balancer"
internal = false
load_balancer_type = "application"
security_groups = [aws_security_group.web_sg.id]
subnets = [aws_subnet.public_subnet.id]
name = "app-target-group"
port = 80
protocol = "HTTP"
vpc_id = aws_vpc.main_vpc.id
load_balancer_arn = aws_lb.app_lb.arn
port = 80
protocol = "HTTP"
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.app_tg.arn
terraform init
1. Find a running EC2 instance from the Auto Scaling Group.
2. Manually terminate the instance from the AWS Console.
3. Auto Scaling should automatically launch a new instance to replace it.
Conclusion
Introduction
yaml
AWSTemplateFormatVersion: "2010-09-09"
Resources:
MyS3Bucket:
Type: "AWS::S3::Bucket"
MyEC2Instance:
Type: "AWS::EC2::Instance"
Properties:
InstanceType: "t2.micro"
python
import boto3
cf_client = boto3.client('cloudformation')
response = cf_client.create_stack(
StackName="MyEventTriggeredStack",
TemplateURL="https://s3.amazonaws.com/my-bucket/cloudformation-template.ya
ml",
Capabilities=['CAPABILITY_NAMED_IAM']
)
return response
● Upload the script as a Lambda function and grant it IAM permissions for
CloudFormation execution.
json
"source": ["aws.s3"],
"detail": {
"bucket": {
"name": ["my-trigger-bucket"]
}
Step 4: Test the Event-Driven Deployment
Conclusion
Project 9: Automated EC2 Scaling Based on Load – Use Auto Scaling policies
with CloudWatch to optimize cost and performance.
Introduction
AWS Auto Scaling ensures that your EC2 instances dynamically adjust based on
real-time traffic and workload demands. By integrating Auto Scaling with
CloudWatch, you can optimize costs by automatically adding or removing
instances based on CPU utilization or other metrics. This ensures high availability,
fault tolerance, and efficient resource management.
1. Generate high CPU load on an instance (e.g., using stress tool in Linux).
2. Verify in CloudWatch if the alarm triggers scaling.
3. Check EC2 Instances to see if new instances are launched or terminated
based on load.
Conclusion
This AWS project demonstrates how Auto Scaling Groups (ASG) and
CloudWatch Alarms help dynamically adjust EC2 instances based on CPU
utilization, optimizing performance and cost. This setup ensures your application
remains highly available and scales automatically according to demand.
Project 1: IAM Role & Policy Management – Secure AWS resources using IAM
policies.
Introduction
AWS Identity and Access Management (IAM) allows secure control over AWS
resources by defining permissions using IAM roles and policies. This project
focuses on creating IAM users, roles, and policies to enforce least-privilege access,
ensuring security and compliance.
"Version": "2012-10-17",
"Statement": [
"Effect": "Allow",
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::example-bucket"
},
"Effect": "Allow",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::example-bucket/*"
2.
3. Click Next → Name Policy (e.g., S3ReadOnlyPolicy) → Create Policy.
Conclusion
This project demonstrated secure AWS resource access using IAM roles and
policies. By applying least privilege principles, we ensured controlled access to
AWS services, improving security and compliance.
Introduction
AWS Secrets Manager is a secure service that helps manage sensitive information
like database credentials, API keys, and other secrets. It automates secret rotation,
provides fine-grained access control, and integrates seamlessly with AWS services,
ensuring enhanced security.
python
import boto3
import json
response = client.get_secret_value(SecretId='mydb-credentials')
secret = json.loads(response['SecretString'])
db_username = secret['username']
db_password = secret['password']
1. Attach an IAM policy to the application or Lambda function needing access.
2. Example IAM policy:
json
"Version": "2012-10-17",
"Statement": [
"Effect": "Allow",
"Action": "secretsmanager:GetSecretValue",
"Resource":
"arn:aws:secretsmanager:us-east-1:123456789012:secret:mydb-credentials"
Conclusion
AWS Secrets Manager provides a secure, automated, and scalable way to store
and manage sensitive credentials. It improves security by preventing hardcoded
secrets and enabling automatic rotation.
Introduction
Amazon API Gateway allows developers to create, deploy, and manage APIs
securely. To enhance security, AWS Cognito provides user authentication, while
AWS Web Application Firewall (WAF) protects APIs from common web threats
like SQL injection and cross-site scripting (XSS). This project demonstrates how to
secure an API Gateway using AWS Cognito for authentication and AWS WAF
for protection.
Steps to Implement
Conclusion
This setup ensures secure authentication with Cognito and protection against
threats using AWS WAF, making API Gateway more robust.
Project 4: AWS Security Hub & GuardDuty – Monitor security threats and
enforce compliance.
Introduction
AWS Security Hub and Amazon GuardDuty are two essential AWS security
services that help monitor, detect, and respond to security threats in your AWS
environment.
By integrating Security Hub with GuardDuty, you can automate threat detection,
centralize security findings, and improve incident response.
1. Sign in to the AWS Management Console and navigate to AWS Security
Hub.
2. Click Enable Security Hub to start monitoring your AWS account.
3. Choose the compliance standards you want to enable (CIS, PCI DSS, AWS
Foundational Security Best Practices).
4. (Optional) If using multiple AWS accounts, configure Security Hub in AWS
Organizations for centralized security management.
Step 2: Enable Amazon GuardDuty
Conclusion
By setting up AWS Security Hub and GuardDuty, you gain real-time visibility into
security threats, automate compliance checks, and improve incident response with
automated remediation. This integration helps in proactively securing your AWS
environment and enforcing compliance at scale.
Introduction
Complete Steps
Conclusion
Introduction
Zero Trust Security is a security model that enforces strict access controls and
continuous verification for all users, devices, and applications. It assumes that no
entity—inside or outside the network—should be trusted by default. In AWS, Zero
Trust can be implemented using IAM (Identity and Access Management) for
identity-based security and VPC Security Groups for network-level security.
Attach a custom policy with the minimum necessary permissions. Example policy:
json
{
"Version": "2012-10-17",
"Statement": [
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::my-secure-bucket",
"arn:aws:s3:::my-secure-bucket/*"
}
Attach the role to your EC2 instances or services that need restricted access.
"Version": "2012-10-17",
"Statement": [
"Effect": "Deny",
"Action": "*",
"Resource": "*",
"Condition": {
"BoolIfExists": {
"aws:MultiFactorAuthPresent": false
]
}
1. Go to VPC > Security Groups and create a new Security Group.
2. Configure inbound rules with strict access control:
○ Allow SSH (port 22) only from a trusted IP.
○ Allow HTTP/HTTPS (ports 80, 443) only from CloudFront or ALB.
○ Block all other traffic by default.
3. Example rules:
Conclusion
Introduction:
AWS CloudTrail records all API activity across AWS services, helping in security
analysis and compliance auditing. Integrating CloudTrail logs with a Security
Information and Event Management (SIEM) tool enables real-time monitoring,
threat detection, and security incident response.
"Version": "2012-10-17",
"Statement": [
"Effect": "Allow",
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::your-bucket-name/AWSLogs/*"
🔹 For Splunk:
● Install Splunk AWS Add-on.
● Configure an S3 input for CloudTrail logs.
● Set up a Splunk index for security events.
By integrating AWS CloudTrail logs with a SIEM tool, you enhance real-time
security monitoring and threat detection. This setup helps organizations meet
compliance requirements and improve cloud security posture.
Project 8: AWS WAF for Application Security – Protect a web application from
SQL injection and XSS attacks using AWS WAF.
AWS Web Application Firewall (WAF) helps protect web applications from
common threats such as SQL injection, cross-site scripting (XSS), and other
OWASP Top 10 vulnerabilities. By using AWS WAF, you can create rules to filter
and block malicious traffic before it reaches your application.
Project Steps
1. Prerequisites
● An AWS account
● A running web application hosted on Amazon API Gateway, Application
Load Balancer (ALB), or CloudFront
● IAM permissions to create and manage AWS WAF resources
8. Validate Security
With this setup, your web application is protected against SQL injection, XSS, and
other web attacks using AWS WAF.
5. CI/CD Projects:
Introduction
Complete Steps
phases:
install:
runtime-versions:
java: corretto11
build:
commands:
artifacts:
files:
- target/*.jar
1. Use AWS CodeDeploy, AWS Lambda, or Amazon ECS for deployment.
2. If using EC2/On-Premises deployment:
○ Install the CodeDeploy agent on EC2 instances.
○ Create an AppSpec file for deployment.
○ Define deployment configuration in CodeDeploy.
Conclusion
GitHub Actions allows you to automate your CI/CD pipeline, and AWS ECS
(Elastic Container Service) is used to deploy containerized applications. Below is a
step-by-step guide to deploying an application from GitHub to AWS ECS using
GitHub Actions.
Step 1: Prerequisites
json
{
"family": "my-task",
"networkMode": "awsvpc",
"containerDefinitions": [
"name": "my-container",
"image":
"<AWS_ACCOUNT_ID>.dkr.ecr.<AWS_REGION>.amazonaws.com/my-repo:lat
est",
"memory": 512,
"cpu": 256,
"essential": true
}
]
2.
○ Register the task:
sh
aws ecs register-task-definition --cli-input-json file://task-definition.json
3.
● AWS_ACCESS_KEY_ID
● AWS_SECRET_ACCESS_KEY
● AWS_REGION
● ECR_REPOSITORY_NAME
● ECS_CLUSTER
● ECS_SERVICE
● TASK_DEFINITION
Step 4: Configure GitHub Actions Workflow
yaml
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
uses: actions/checkout@v4
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, Tag, and Push Docker Image
env:
run: |
docker build -t
$ECR_REGISTRY/$ECR_REPOSITORY_NAME:$IMAGE_TAG .
docker push
$ECR_REGISTRY/$ECR_REPOSITORY_NAME:$IMAGE_TAG
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: task-definition.json
container-name: my-container
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
cluster: ${{ secrets.ECS_CLUSTER }}
wait-for-service-stability: true
git add .
This triggers the GitHub Actions workflow, building the image, pushing it to ECR,
and updating ECS.
Conclusion
Now, your GitHub Actions pipeline will automatically deploy to AWS ECS
whenever you push changes to the main branch.
Introduction
1. Prerequisites
● AWS Account
● EC2 instance for Jenkins (Ubuntu preferred)
● IAM role and user for Terraform with required permissions
● S3 bucket and DynamoDB table for Terraform state management
● Jenkins installed on the EC2 instance
● Terraform installed on the Jenkins server
Open port 8080 in AWS Security Group and get the admin password:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
● Install necessary Jenkins plugins:
○ Terraform
○ AWS Credentials
○ Git
○ Pipeline
unzip terraform_1.7.0_linux_amd64.zip
terraform -v
hcl
provider "aws" {
region = "us-east-1"
ami = "ami-0c55b159cbfafe1f0"
instance_type = "t2.micro"
key_name = "my-key"
tags = {
Name = "Jenkins-Server"
Initialize Terraform:
terraform init
terraform validate
5. Set Up Jenkins Pipeline for Terraform
groovy
pipeline {
agent any
environment {
AWS_ACCESS_KEY_ID = credentials('AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY =
credentials('AWS_SECRET_ACCESS_KEY')
stages {
stage('Checkout Code') {
steps {
git 'https://github.com/your-repo/terraform-aws.git'
stage('Initialize Terraform') {
steps {
sh 'terraform init'
}
}
stage('Plan Terraform') {
steps {
sh 'terraform plan'
stage('Apply Terraform') {
steps {
● Go to AWS Console
● Check if EC2, S3, RDS, or other services were provisioned
8. Destroy Infrastructure (Optional)
Conclusion
Introduction
GitOps is a DevOps approach where Git repositories serve as the source of truth
for infrastructure and application deployment. ArgoCD is a declarative, GitOps
continuous delivery tool for Kubernetes, ensuring that the desired application state
in Git matches the running state in a Kubernetes cluster.
In this project, we'll set up ArgoCD on AWS EKS to enable automated application
deployment and management.
Complete Steps
1. Prerequisites
● AWS account
● AWS CLI installed & configured
● kubectl installed
● eksctl installed
● Helm installed
● GitHub repository for GitOps
Create a namespace:
Verify installation:
Login using:
Example app.yaml:
yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: my-app
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/your-repo.git
targetRevision: main
path: app-manifests
destination:
server: https://kubernetes.default.svc
namespace: default
syncPolicy:
automated:
selfHeal: true
prune: true
6. Verify Deployment
8. Clean Up Resources
To delete everything:
Conclusion
With this setup, ArgoCD continuously syncs your application with Git, automating
Kubernetes deployments on AWS EKS using GitOps principles.
Introduction
phases:
install:
runtime-versions:
nodejs: 18
build:
commands:
- npm install
- zip -r app.zip .
artifacts:
files:
- app.zip
● Configure AWS CodeBuild with IAM permissions, environment variables,
and the buildspec file.
7. Validate Deployment
Introduction
Step 1: Prerequisites
json
"Version": "2012-10-17",
"Statement": [
"Effect": "Allow",
"Principal": { "AWS":
"arn:aws:iam::<MANAGEMENT_ACCOUNT_ID>:root" },
"Action": "sts:AssumeRole"
Example buildspec.yml:
yaml
version: 0.2
phases:
install:
runtime-versions:
nodejs: 14
build:
commands:
- npm install
post_build:
commands:
files: '**/*'
Conclusion
Introduction
AWS Fargate is a serverless compute engine for containers that allows you to run
and manage Docker containers without managing the underlying infrastructure. It
integrates with Amazon ECS (Elastic Container Service) and Amazon EKS
(Elastic Kubernetes Service), but here we will focus on ECS with Fargate.
1. Prerequisites
● AWS Account
● AWS CLI installed and configured (aws configure)
● Docker installed
● An ECS cluster
docker push
<AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/my-fargate-app:latest
json
"family": "my-fargate-task",
"networkMode": "awsvpc",
"requiresCompatibilities": ["FARGATE"],
"cpu": "256",
"memory": "512",
"executionRoleArn":
"arn:aws:iam::AWS_ACCOUNT_ID:role/ecsTaskExecutionRole",
"containerDefinitions": [
"name": "my-fargate-app",
"image":
"<AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/my-fargate-app:latest
",
"portMappings": [
"containerPort": 80,
"hostPort": 80,
"protocol": "tcp"
--cluster my-fargate-cluster \
--service-name my-fargate-service \
--task-definition my-fargate-task \
--launch-type FARGATE \
--network-configuration
"awsvpcConfiguration={subnets=[subnet-abc123],securityGroups=[sg-abc123],ass
ignPublicIp=ENABLED}" \
--desired-count 1
6. Verify Deployment
7. Clean Up Resources
Introduction:
Blue-Green Deployment is a release management strategy that reduces downtime
and risk by running two identical environments, Blue (current version) and Green
(new version). In AWS ECS, this ensures smooth application updates without
downtime.
6. DevOps Projects:
Introduction
Infrastructure as Code (IaC) is a method of managing and provisioning cloud
infrastructure using code. Terraform, developed by HashiCorp, is a popular IaC
tool that allows you to define AWS infrastructure in a declarative way. With
Terraform, you can create, modify, and delete AWS resources efficiently and
consistently.
Prerequisites
sh
Create a file named main.tf and add the following Terraform script:
hcl
provider "aws" {
instance_type = "t2.micro"
tags = {
Name = "Terraform-EC2"
terraform init
terraform validate
Step 5: Plan the Infrastructure Deployment
terraform plan
Check the AWS Console (EC2 Dashboard) to confirm that the instance has been
created.
Conclusion
Introduction
Project Overview
1. Create an Amazon Machine Image (AMI) from this instance for scaling.
1. Navigate to EC2 → Auto Scaling Groups → Create Auto Scaling Group
2. Configure:
○ Launch Template: Choose the one created earlier
○ VPC & Subnets: Select public subnets
○ Attach to Load Balancer: Select the target group from Step 3
○ Desired Capacity: 2 (initial number of instances)
○ Min/Max Instances: Set min = 1, max = 3
○ Scaling Policies: Add scaling based on CPU utilization
■ Scale Out Policy: Add an instance when CPU > 70%
■ Scale In Policy: Remove an instance when CPU < 30%
2. This will increase CPU usage and trigger a scale-out event.
3. CloudWatch will detect lower CPU usage and remove extra instances.
Summary
Introduction
AWS CloudWatch collects logs, metrics, and events from AWS services, while
ELK Stack provides log aggregation, visualization, and analysis.
Project Steps
sudo amazon-cloudwatch-agent-config-wizard
wget
https://artifacts.elastic.co/downloads/logstash/logstash-7.17.9-linux-x86_64.tar.gz
wget
https://artifacts.elastic.co/downloads/kibana/kibana-7.17.9-linux-x86_64.tar.gz
discovery.type: single-node
Start Elasticsearch:
sudo systemctl start elasticsearch
file {
output {
elasticsearch {
Start Logstash:
sudo systemctl start logstash
server.host: "0.0.0.0"
Start Kibana:
sudo systemctl start kibana
input {
s3 {
Final Steps
This setup provides real-time monitoring, centralized logging, and alerting for
AWS infrastructure.
1. Prerequisites
For Windows:
Get-Service AmazonSSMAgent
If not installed, install using:
sudo yum install -y amazon-ssm-agent
Conclusion
AWS SSM Patch Manager simplifies patching by automating security updates for
EC2 instances, ensuring compliance with security policies. By following these
steps, you can efficiently manage patching operations with minimal manual effort.
Project Steps
Outcome
By implementing IAM security best practices and AWS Config Rules, this
project ensures a secure AWS environment, reduces risks of misconfigurations,
and enhances compliance with security standards like CIS AWS Benchmark.
Introduction
By automating backups with AWS Backup and using Route 53 for DNS failover,
you ensure quick recovery in case of disasters. This setup minimizes downtime and
ensures business continuity.
Introduction
AWS Lambda can help reduce costs by automatically stopping idle or unused EC2
instances. This solution involves using AWS Lambda with CloudWatch and IAM
to detect and shut down instances that are not in use, ensuring cost savings.
Steps to Implement
python
import boto3
ec2 = boto3.client('ec2')
response = ec2.describe_instances(
instances_to_stop = []
instances_to_stop.append(instance['InstanceId'])
if instances_to_stop:
ec2.stop_instances(InstanceIds=instances_to_stop)
else:
● Click Deploy
Conclusion
Introduction
● Launch an EC2 instance and configure it with the required application setup.
● Create an Amazon Machine Image (AMI) of this instance for auto-scaling.
● In the Auto Scaling Group, define EC2 health checks and ELB health
checks to detect unhealthy instances.
● Enable the Replace Unhealthy Instances option to automatically replace
failed instances.
● Manually terminate an instance in the Auto Scaling Group and observe how
AWS automatically launches a replacement.
● Stress test the application to see how Auto Scaling responds to demand
changes.
Conclusion
This setup ensures that application instances are automatically replaced if they fail,
and resources scale dynamically based on demand. By leveraging Auto Scaling,
ELB, and CloudWatch, AWS enables a highly available and resilient self-healing
infrastructure.
Introduction:
sql
CREATE DATABASE myappdb;
USE myappdb;
name VARCHAR(50),
);
Conclusion:
This project demonstrates how to deploy, secure, and manage a MySQL database
on AWS RDS. With monitoring, scaling, and backup strategies, your database
remains highly available and optimized for production use.
Introduction:
In this project, you will create a serverless backend using AWS Lambda to
perform CRUD (Create, Read, Update, Delete) operations on an Amazon
DynamoDB table. AWS API Gateway will expose RESTful APIs, triggering
Lambda functions to interact with DynamoDB. This setup ensures a fully
serverless and scalable backend without managing any servers.
Steps to Implement:
python
import json
import boto3
import uuid
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('UsersTable')
user_id = str(uuid.uuid4())
item = {
'userId': user_id,
'name': data['name'],
'email': data['email']
table.put_item(Item=item)
return {
'statusCode': 201,
● Click Deploy
python
import json
import boto3
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('UsersTable')
user_id = event['pathParameters']['userId']
if 'Item' in response:
python
import json
import boto3
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('UsersTable')
def lambda_handler(event, context):
user_id = event['pathParameters']['userId']
data = json.loads(event['body'])
table.update_item(
Key={'userId': user_id},
ExpressionAttributeNames={'#n': 'name'},
python
import json
import boto3
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('UsersTable')
user_id = event['pathParameters']['userId']
table.delete_item(Key={'userId': user_id})
Project 3: Data Warehouse with AWS Redshift – Store and analyze structured
data in Redshift.
1. Prerequisites
● An AWS account
● IAM role with required permissions
● Basic knowledge of SQL and AWS services
FROM 's3://your-bucket-name/data.csv'
IAM_ROLE 'arn:aws:iam::account-id:role/your-redshift-role'
CSV
IGNOREHEADER 1;
6. Run Queries & Analyze Data
Create a table:
sql
CREATE TABLE sales_data (
id INT,
product_name VARCHAR(255),
price DECIMAL(10,2),
quantity INT,
sale_date DATE
);
FROM sales_data
GROUP BY product_name
Conclusion
By following these steps, you have successfully created an AWS Redshift data
warehouse, loaded structured data, and analyzed it using SQL queries. This setup is
scalable for enterprise data analytics.
Project 4: ETL with AWS Glue – Transform data from S3 to Redshift using AWS
Glue.
Introduction
AWS Glue is a fully managed Extract, Transform, Load (ETL) service that helps
prepare and move data from various sources to a data warehouse like Amazon
Redshift. In this project, we will use AWS Glue to extract data stored in Amazon
S3, transform it using AWS Glue ETL scripts, and load it into an Amazon Redshift
table.
1. Prerequisites
● AWS Account
● IAM roles with necessary permissions for AWS Glue, S3, and Redshift
● Amazon S3 bucket with sample data (CSV or JSON)
● Amazon Redshift cluster
2. Create and Configure Amazon Redshift
id INT,
customer_name VARCHAR(100),
amount FLOAT,
date DATE
);
4. Save the JDBC URL of the Redshift cluster for AWS Glue connection.
python
import sys
sc = SparkContext()
glueContext = GlueContext(sc)
spark = glueContext.spark_session
job = Job(glueContext)
job.init(args['JOB_NAME'], args)
s3_df = glueContext.create_dynamic_frame.from_catalog(
database="my_glue_database",
table_name="sales_data"
df = s3_df.toDF()
df = df.withColumnRenamed("id", "customer_id")
glueContext.write_dynamic_frame.from_jdbc_conf(
frame=transformed_df,
catalog_connection="redshift_connection",
connection_options={
"dbtable": "sales_data",
"database": "dev"
job.commit()
sql
SELECT * FROM sales_data;
Conclusion
You have successfully set up an ETL pipeline using AWS Glue to extract data
from Amazon S3, transform it using PySpark, and load it into Amazon Redshift.
Introduction
Amazon Neptune is a managed graph database service that supports both property
graph (Gremlin) and RDF graph (SPARQL) models. It enables efficient storage
and querying of highly connected data, making it suitable for applications like
recommendation engines, fraud detection, and social networks.
1. Prerequisites
● AWS Account
● IAM role with Amazon Neptune permissions
● Amazon VPC with a private subnet
● Amazon Neptune Cluster
2. Create an Amazon Neptune Cluster
1,Person,Alice,30
2,Person,Bob,35
3,Person,Charlie,25
102,2,3,knows,2018
--source s3://my-neptune-data/nodes.csv \
--format csv \
--iam-role arn:aws:iam::123456789012:role/NeptuneLoadRole
--source s3://my-neptune-data/edges.csv \
--format csv \
--iam-role arn:aws:iam::123456789012:role/NeptuneLoadRole
Conclusion
Introduction
Amazon S3 (Simple Storage Service) provides lifecycle policies that allow
automatic data archival and deletion. This project sets up an automated process
where data stored in an S3 bucket is automatically moved to Amazon S3 Glacier
for cost-effective long-term storage.
Steps to Implement
1. Wait for the configured time period (or adjust settings to test quickly).
2. Check object storage class changes in the Objects tab (should show Glacier
after transition).
Conclusion
This project automates data archival using S3 lifecycle rules, reducing storage
costs by moving older data to Amazon Glacier while keeping it retrievable when
needed.
AWS Database Migration Service (AWS DMS) helps migrate databases to AWS
quickly and securely with minimal downtime. In this project, we will migrate a
MySQL database to Amazon Aurora using AWS DMS.
log_bin=mysql-bin
binlog_format=row
expire_logs_days=1
Restart MySQL and create a user for DMS with necessary privileges:
CREATE USER 'dms_user'@'%' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
Project 1: Monitor AWS Resources with CloudWatch & SNS – Set up alerts for
EC2, RDS, and S3.
Introduction
Complete Steps
1. Trigger an alert (e.g., Increase CPU usage in EC2 using a stress test)
2. Check CloudWatch Alarms dashboard
3. Verify if SNS sends a notification to the configured channel
Conclusion
Project 2: Log Analysis with ELK Stack – Deploy Elasticsearch, Logstash, and
Kibana on AWS.
The ELK Stack (Elasticsearch, Logstash, and Kibana) is a powerful toolset for log
management and analysis. This project demonstrates how to deploy the ELK stack
on AWS to collect, process, and visualize logs in real time.
discovery.type: single-node
beats {
filter {
grok {
output {
elasticsearch {
}
}
elasticsearch.hosts: ["http://localhost:9200"]
hosts: ["localhost:5044"]
Final Validation
Conclusion
This setup enables real-time log collection, processing, and visualization using
AWS EC2 and the ELK stack. You can extend this project by integrating AWS
services like CloudWatch Logs, Lambda, and S3 for enhanced log storage and
monitoring.
Introduction
A serverless URL monitor helps check website uptime using AWS Lambda and
CloudWatch. AWS Lambda functions execute on a scheduled interval to send
HTTP requests to a specified URL and log the response. CloudWatch Alarms
notify users if the website is down. This eliminates the need for a dedicated server,
reducing costs and management overhead.
Steps to Implement
● In the Lambda function editor, replace the default code with the following
(Python example):
python
import json
import requests
import boto3
import os
try:
status = response.status_code
if status == 200:
else:
def send_alert(message):
sns_client = boto3.client("sns")
sns_client.publish(
TopicArn=os.getenv('SNS_TOPIC_ARN'),
Message=message,
Outcome
The Lambda function will periodically check the website's uptime and send an alert
via SNS if the site is down. CloudWatch Logs help track availability metrics.
Enhancements
Project 4: Query S3 Logs with AWS Athena – Analyze stored logs without
setting up a database.
Introduction
A serverless URL monitor helps check website uptime using AWS Lambda and
CloudWatch. AWS Lambda functions execute on a scheduled interval to send
HTTP requests to a specified URL and log the response. CloudWatch Alarms
notify users if the website is down. This eliminates the need for a dedicated server,
reducing costs and management overhead.
Steps to Implement
● In the Lambda function editor, replace the default code with the following
(Python example):
python
import json
import requests
import boto3
import os
try:
status = response.status_code
if status == 200:
else:
except requests.RequestException:
def send_alert(message):
sns_client = boto3.client("sns")
sns_client.publish(
TopicArn=os.getenv('SNS_TOPIC_ARN'),
Message=message,
)
● Set Environment Variables:
○ MONITOR_URL → Website URL to check.
○ SNS_TOPIC_ARN → ARN of an SNS topic for notifications.
Outcome
The Lambda function will periodically check the website's uptime and send an alert
via SNS if the site is down. CloudWatch Logs help track availability metrics.
Enhancements
Introduction
AWS X-Ray is a distributed tracing service that helps developers analyze and
debug applications running in production or development. It provides insights into
application requests, latency, and dependencies across microservices, improving
performance and troubleshooting issues efficiently. X-Ray is particularly useful for
AWS Lambda, API Gateway, EC2, ECS, and containerized applications.
1. Prerequisites
● AWS account
● An application running on EC2, ECS, Lambda, or API Gateway
● AWS CLI and IAM permissions
app = Flask(__name__)
xray_recorder.configure(service='MyApp')
XRayMiddleware(app, xray_recorder)
@app.route('/')
def index():
app.run()
●
AWSXRay.captureHTTPsGlobal(require('http'));
app.use(AWSXRay.express.openSegment('MyApp'));
res.send('Hello, X-Ray!');
});
app.use(AWSXRay.express.closeSegment());
app.listen(3000, () => console.log('Server running on port 3000'));
"Effect": "Allow",
"Action": [
"xray:PutTraceSegments",
"xray:PutTelemetryRecords",
"xray:GetSamplingRules"
],
"Resource": "*"
Conclusion
AWS X-Ray provides deep visibility into application performance, helping
developers trace requests, analyze bottlenecks, and optimize their architecture. By
integrating X-Ray with EC2, Lambda, or API Gateway, you can monitor
distributed applications efficiently.
Project 1: Route 53 DNS Management – Configure and manage DNS records for
custom domains.
Introduction
Amazon Route 53 is a scalable and highly available Domain Name System (DNS)
web service. It helps route end users to applications by translating domain names
(e.g., example.com) into IP addresses. In this project, you will configure and
manage DNS records for a custom domain using Route 53.
● If you don’t have a domain, register one using Route 53 or any domain
registrar like GoDaddy, Namecheap, etc.
● If using Route 53:
1. Navigate to AWS Route 53 Console.
2. Click "Registered domains" > "Register Domain".
3. Choose a domain, provide details, and complete the purchase.
● Click on your Hosted Zone and add records based on your needs:
○ A Record (IPv4 Address) – Maps domain to an IP.
○ CNAME Record – Maps domain to another domain (e.g.,
www.example.com → example.com).
○ MX Record – Routes email for your domain.
○ TXT Record – Used for domain verification (e.g., AWS SES, Google
Workspace).
Conclusion
With Route 53, you can efficiently manage DNS for your custom domain, ensuring
high availability, traffic control, and integration with AWS services.
Introduction
AWS Transit Gateway is a networking service that enables secure and scalable
communication between multiple Amazon Virtual Private Clouds (VPCs) and
on-premises networks. It acts as a central hub, simplifying network management
by reducing the number of direct VPC-to-VPC peering connections. This is ideal
for large-scale deployments where multiple VPCs need to communicate securely
without complex peering configurations.
Steps to Set Up AWS Transit Gateway for Multi-VPC Communication
Conclusion
Introduction
Step 1: Prerequisites
yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
replicas: 2
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: my-app
image: <aws_account_id>.dkr.ecr.us-east-1.amazonaws.com/my-app
ports:
- containerPort: 80
sh
yaml
apiVersion: v1
kind: Service
metadata:
name: my-app-service
spec:
type: LoadBalancer
selector:
app: my-app
ports:
- protocol: TCP
port: 80
targetPort: 80
sh
Conclusion
Project 4: Hybrid Cloud Setup with AWS VPN – Connect an on-premises data
center to AWS.
traceroute 10.0.1.10
1. Update Security Groups and NACLs to allow traffic from on-premises IP
ranges.
2. Use AWS Network Firewall or VPN Monitoring for security.
Conclusion
Project 1: Big Data Processing with AWS EMR – Use Apache Spark to analyze
large datasets.
Introduction
Amazon EMR (Elastic MapReduce) is a managed big data framework that allows
you to process large datasets efficiently using Apache Spark, Hadoop, and other
frameworks. EMR simplifies data processing, making it scalable and cost-effective
for various analytical workloads.
In this project, you will use Apache Spark on AWS EMR to analyze large datasets
stored in Amazon S3.
1. Set Up Prerequisites
You can launch an EMR cluster using the AWS Console or AWS CLI.
--name "Spark-Cluster" \
--release-label emr-6.7.0 \
--applications Name=Spark \
--instance-type m5.xlarge \
--instance-count 3 \
--use-default-roles \
--ec2-attributes KeyName=your-key
3. Upload Data to S3
spark-shell
scala
data.groupBy("column_name").count().show()
After processing, you can stop or terminate the cluster to save costs:
Conclusion
This project demonstrates how to process large datasets using Apache Spark on
AWS EMR. By leveraging EMR’s managed cluster, you can efficiently run big
data analytics without managing infrastructure.
Introduction
AWS Kinesis is a cloud-based service that enables real-time data processing from
IoT devices, social media, application logs, and other data sources. It allows
organizations to ingest, analyze, and process streaming data efficiently. Kinesis
provides different services like Kinesis Data Streams, Kinesis Data Firehose,
and Kinesis Data Analytics for real-time data handling.
In this project, we will use Kinesis Data Streams to collect real-time data,
Lambda to process it, and DynamoDB to store the processed data.
import boto3
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('IoTData')
payload = json.loads(record['kinesis']['data'])
table.put_item(Item={
'device_id': payload['device_id'],
'timestamp': payload['timestamp'],
'temperature': payload['temperature']
})
python
import boto3
import json
import time
import random
kinesis_client = boto3.client('kinesis')
stream_name = 'IoT-Data-Stream'
while True:
data = {
'device_id': 'sensor-1',
'timestamp': int(time.time()),
response = kinesis_client.put_record(
StreamName=stream_name,
Data=json.dumps(data),
PartitionKey='sensor-1'
time.sleep(5)
Conclusion
This project demonstrates how to set up a real-time data streaming pipeline with
AWS Kinesis, Lambda, and DynamoDB. It allows continuous data ingestion,
processing, and storage, making it suitable for IoT telemetry and social media data
analysis.
Introduction
Conclusion
With AWS QuickSight, sales teams can track real-time revenue, identify
top-performing products, and analyze customer trends to make data-driven
decisions.
Project 4: AWS Athena for Log Analysis – Query CloudTrail and VPC Flow
Logs using Athena.
Introduction
AWS Athena is a serverless query service that allows you to analyze data in
Amazon S3 using standard SQL. It is commonly used for log analysis, including
CloudTrail logs (which track API activity in AWS) and VPC Flow Logs (which
capture network traffic metadata). By leveraging Athena, you can quickly search,
filter, and gain insights from your AWS logs without needing a traditional
database.
● CloudTrail Logs:
1. Go to the AWS Management Console → CloudTrail
2. Click Create trail and configure:
■ Enable Management events
■ Store logs in an S3 bucket
3. Click Create
● VPC Flow Logs:
1. Navigate to EC2 Dashboard → Network Interfaces
2. Select a VPC, click Flow Logs, then Create Flow Log
3. Choose Amazon S3 as the destination
4. Click Create
1. Go to Amazon S3
2. Click Create bucket
3. Set a unique name (e.g., my-log-bucket)
4. Ensure the bucket has public access blocked
5. Click Create bucket
● Set Up Athena:
1. Open AWS Athena
2. Click Settings → Set query results location to the S3 bucket (e.g.,
s3://my-log-bucket/athena-results/)
● Create a Database in Athena:
CloudTrail Table:
sql
CREATE EXTERNAL TABLE cloudtrail_logs (
eventVersion STRING,
eventTime STRING,
eventSource STRING,
eventName STRING,
awsRegion STRING,
sourceIPAddress STRING,
userAgent STRING
LOCATION 's3://my-log-bucket/AWSLogs/{account-id}/CloudTrail/'
version INT,
account_id STRING,
interface_id STRING,
srcaddr STRING,
dstaddr STRING,
srcport INT,
dstport INT,
protocol INT,
packets INT,
bytes INT,
start_time INT,
end_time INT,
action STRING,
log_status STRING
LOCATION 's3://my-log-bucket/vpc-flow-logs/';
FROM cloudtrail_logs
FROM vpc_flow_logs
Conclusion
This project helps monitor AWS security and network activity using Athena's SQL
queries on CloudTrail and VPC Flow Logs. Since Athena is serverless, you only
pay for the queries you run, making it an efficient solution for log analysis.
Introduction
AWS SageMaker is a fully managed machine learning (ML) service that simplifies
the process of building, training, and deploying ML models at scale. It supports
various ML frameworks such as TensorFlow, PyTorch, and Scikit-Learn, along
with built-in algorithms for common ML tasks. In this project, we will use AWS
SageMaker to train an ML model for predictive analytics and deploy it as an
endpoint for real-time predictions.
Complete Steps
1. Set Up AWS SageMaker Environment
s3_bucket = "your-bucket-name"
dataset_path = f"s3://{s3_bucket}/your-dataset.csv"
df = pd.read_csv(dataset_path)
df.to_csv("processed_data.csv", index=False)
sagemaker_session = sagemaker.Session()
s3_data_path = S3Uploader.upload("processed_data.csv",
f"s3://{s3_bucket}/processed/")
instance_count=1,
instance_type="ml.m4.xlarge",
predictor_type="binary_classifier",
output_path=f"s3://{s3_bucket}/output/")
prediction = predictor.predict(test_sample)
print("Prediction:", prediction)
6. Clean Up Resources
Conclusion
This project demonstrated how to use AWS SageMaker to train and deploy an ML
model for predictive analytics. By leveraging SageMaker's built-in algorithms and
managed infrastructure, ML development becomes faster and more scalable.
Introduction
Complete Steps
● Use publicly available datasets like Kaggle’s Credit Card Fraud Dataset
or your organization's dataset.
● Preprocess the dataset:
○ Handle missing values.
○ Normalize numerical features.
○ Encode categorical data if needed.
○ Split the dataset into training (80%) and testing (20%).
● Upload the dataset to an S3 bucket for storage.
Conclusion
--region your-region
--image "S3Object={Bucket=your-bucket-name,Name=image.jpg}" \
--region your-region
--image "S3Object={Bucket=your-bucket-name,Name=image.jpg}" \
--region your-region
python
import boto3
rekognition = boto3.client("rekognition")
response = rekognition.detect_labels(
print(f"{label['Name']} - {label['Confidence']:.2f}%")
Conclusion
Project 4: IoT Data Processing with AWS IoT Core – Store and analyze IoT
sensor data in AWS.
AWS IoT Core is a managed cloud service that enables connected IoT devices to
communicate securely with AWS services. This project focuses on collecting,
storing, and analyzing IoT sensor data using AWS IoT Core, Amazon Kinesis, and
Amazon S3.
Project Steps
Conclusion
This project demonstrates how to securely process IoT sensor data using AWS IoT
Core, store it in Amazon S3 or DynamoDB, analyze it with AWS Kinesis, and
visualize it using QuickSight. By integrating CloudWatch monitoring, you can
ensure real-time tracking and security for your IoT ecosystem.
Introduction
● Upload files to the primary bucket and check if they are replicated to the
backup bucket.
1. Test S3 Replication: Upload a file to the primary bucket and verify
replication.
2. Test RDS Read Replica: Run queries on the read replica to check for data
consistency.
3. Simulate Failover: Stop the primary instance and validate automatic traffic
redirection to the backup region.
Conclusion
Project 2: AWS Backup for EBS Snapshots & Recovery – Automate backups
and restore EC2 instances.
Introduction
AWS Backup is a fully managed service that automates the backup and recovery of
AWS resources, including EBS volumes. In this project, we will configure AWS
Backup to create automated snapshots of Amazon EBS volumes and restore EC2
instances from these snapshots in case of data loss or failures.
1. Wait for the scheduled backup to trigger or manually start it.
2. Go to AWS Backup → Backup jobs to monitor progress.
3. Verify that EBS snapshots are created in Amazon EC2 → Snapshots.
Conclusion
By automating EBS backups with AWS Backup, you ensure business continuity by
regularly creating snapshots and quickly restoring EC2 instances in case of
failures. This project helps in disaster recovery planning and compliance
management.
Project 3: Automated AMI Creation & Cleanup – Schedule AMI snapshots and
delete old backups.
Introduction
Amazon Machine Images (AMIs) are used to create EC2 instances with
pre-configured environments. Automating AMI creation ensures that backups of
instances are taken regularly, while cleanup of old AMIs helps in cost optimization
by removing unnecessary snapshots. This project sets up a scheduled process using
AWS Lambda, CloudWatch Events, and IAM policies to automate AMI creation
and deletion of outdated backups.
Project Steps
python
import boto3
import datetime
ec2 = boto3.client('ec2')
date = datetime.datetime.now().strftime("%Y-%m-%d")
response = ec2.create_image(
InstanceId=instance,
Name=f"AMI-Backup-{instance}-{date}",
NoReboot=True
python
import boto3
import datetime
ec2 = boto3.client('ec2')
delete_before = datetime.datetime.now() -
datetime.timedelta(days=retention_days)
images = ec2.describe_images(Owners=['self'])['Images']
creation_date = datetime.datetime.strptime(image['CreationDate'],
"%Y-%m-%dT%H:%M:%S.%fZ")
ec2.deregister_image(ImageId=image['ImageId'])
Outcome
● The first Lambda function automatically creates an AMI for specified EC2
instances daily.
● The second Lambda function removes AMIs older than the retention period
(e.g., 7 days).
● CloudWatch schedules ensure automated execution.
● Reduces manual intervention and optimizes storage costs.