Skip to content

izqalan/cloud-practice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AWS DevOps Hands-On Technical Test

Prerequisites

  • AWS Account (Free Tier eligible)
  • AWS CLI installed and configured
  • Basic knowledge of Git, Docker, and Linux
  • Text editor or IDE
  • Time required: 3-4 hours

Task 1: Infrastructure as Code (30 points)

Objective

Create a CloudFormation template that deploys a complete VPC infrastructure.

Requirements

Create a CloudFormation template (vpc-infrastructure.yaml) that provisions:

  1. VPC with CIDR block 10.0.0.0/16
  2. Two public subnets in different AZs (10.0.1.0/24, 10.0.2.0/24)
  3. Two private subnets in different AZs (10.0.10.0/24, 10.0.20.0/24)
  4. Internet Gateway attached to VPC
  5. NAT Gateway in one public subnet
  6. Route tables properly configured:
    • Public route table with route to Internet Gateway
    • Private route table with route to NAT Gateway
  7. Outputs for VPC ID, subnet IDs, and route table IDs

Deliverable

  • CloudFormation YAML file
  • Screenshot of successfully created stack
  • Export the stack outputs

Validation Commands

aws cloudformation create-stack \
  --stack-name devops-vpc-stack \
  --template-body file://vpc-infrastructure.yaml

aws cloudformation describe-stacks \
  --stack-name devops-vpc-stack \
  --query 'Stacks[0].Outputs'

Task 2: EC2 Auto Scaling with Load Balancer (25 points)

Objective

Deploy an auto-scaling web application behind an Application Load Balancer.

Requirements

  1. Launch Template:

    • Amazon Linux 2023 AMI
    • t2.micro instance type
    • User data script that installs and starts nginx
    • Security group allowing HTTP (80) and SSH (22)
  2. Auto Scaling Group:

    • Min: 2, Max: 4, Desired: 2
    • Use the VPC from Task 1 (private subnets)
    • Health check grace period: 300 seconds
    • Scaling policies:
      • Scale out when CPU > 70% for 2 minutes
      • Scale in when CPU < 30% for 5 minutes
  3. Application Load Balancer:

    • Internet-facing
    • In public subnets from Task 1
    • Target group with health checks on port 80
    • Listener on port 80

Deliverable

  • Launch template configuration (CLI commands or console screenshots)
  • Auto Scaling group configuration
  • Load balancer DNS name
  • Screenshot showing 2 healthy instances in target group

Validation

Access the load balancer DNS name in browser - should show nginx welcome page.

# Get ALB DNS name
aws elbv2 describe-load-balancers \
  --query 'LoadBalancers[*].DNSName' \
  --output text

# Test with curl
curl http://<ALB-DNS-NAME>

Task 3: CI/CD Pipeline (35 points)

Objective

Build a complete CI/CD pipeline using AWS native services.

Part A: Prepare the Application (10 points)

  1. Create a simple Node.js application:

app.js:

const express = require('express');
const app = express();
const port = 3000;

app.get('/', (req, res) => {
  res.json({ 
    message: 'DevOps Test App',
    version: '1.0',
    timestamp: new Date().toISOString()
  });
});

app.get('/health', (req, res) => {
  res.status(200).json({ status: 'healthy' });
});

app.listen(port, () => {
  console.log(`App listening on port ${port}`);
});

package.json:

{
  "name": "devops-test-app",
  "version": "1.0.0",
  "scripts": {
    "start": "node app.js",
    "test": "echo 'Tests passed'"
  },
  "dependencies": {
    "express": "^4.18.0"
  }
}
  1. Create CodeBuild buildspec.yml:
version: 0.2

phases:
  install:
    runtime-versions:
      nodejs: 18
  pre_build:
    commands:
      - echo Installing dependencies...
      - npm install
  build:
    commands:
      - echo Build started on `date`
      - npm test
      - echo Building deployment package...
  post_build:
    commands:
      - echo Build completed on `date`

artifacts:
  files:
    - '**/*'
  1. Create CodeDeploy appspec.yml:
version: 0.0
os: linux
files:
  - source: /
    destination: /var/www/devops-app
hooks:
  ApplicationStop:
    - location: scripts/stop_server.sh
      timeout: 300
  AfterInstall:
    - location: scripts/install_dependencies.sh
      timeout: 300
  ApplicationStart:
    - location: scripts/start_server.sh
      timeout: 300
  1. Create deployment scripts in scripts/ folder

  2. Push to CodeCommit repository

Part B: Build the Pipeline (25 points)

Create a CodePipeline with:

  1. Source Stage:

    • CodeCommit repository
    • Branch: main
    • Trigger on commit
  2. Build Stage:

    • CodeBuild project
    • Environment: Amazon Linux 2
    • Build specifications from buildspec.yml
  3. Deploy Stage:

    • CodeDeploy
    • Deployment group targeting Auto Scaling group from Task 2
    • Deployment configuration: CodeDeployDefault.OneAtATime

Deliverable

  • Git repository URL (CodeCommit)
  • Pipeline name and execution screenshot
  • Application accessible through ALB
  • Evidence of successful deployment after code push

Validation

# Push a change and watch pipeline execute
git add .
git commit -m "Update version to 1.1"
git push origin main

# Check pipeline status
aws codepipeline get-pipeline-state \
  --name devops-test-pipeline

Task 4: Container Deployment with ECS (30 points)

Objective

Containerize the application and deploy it on ECS with Fargate.

Requirements

  1. Dockerfile:
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install --production
COPY . .
EXPOSE 3000
CMD ["npm", "start"]
  1. Build and Push to ECR:

    • Create ECR repository
    • Build Docker image
    • Push to ECR
  2. ECS Cluster:

    • Create ECS cluster (Fargate)
    • Create task definition:
      • 0.5 vCPU, 1GB memory
      • Container port 3000
      • CloudWatch Logs enabled
  3. ECS Service:

    • Desired count: 2
    • Application Load Balancer integration
    • Auto-scaling based on CPU (target 70%)
    • Deployment type: Rolling update

Deliverable

  • ECR repository URI
  • Task definition JSON
  • Service name and status
  • Load balancer endpoint serving containerized app

Validation Commands

# Login to ECR
aws ecr get-login-password --region us-east-1 | \
  docker login --username AWS --password-stdin <account-id>.dkr.ecr.us-east-1.amazonaws.com

# Build and push
docker build -t devops-test-app .
docker tag devops-test-app:latest <ecr-uri>:latest
docker push <ecr-uri>:latest

# Describe service
aws ecs describe-services \
  --cluster devops-cluster \
  --services devops-service

Task 5: Monitoring and Alerting (20 points)

Objective

Set up comprehensive monitoring and alerting.

Requirements

  1. CloudWatch Dashboard:

    • ALB request count
    • ALB target response time
    • ECS service CPU and memory utilization
    • Auto Scaling group metrics
  2. CloudWatch Alarms:

    • ALB unhealthy target count > 0
    • ECS service CPU utilization > 80%
    • Auto Scaling group instance count < 2
  3. SNS Topic:

    • Create SNS topic for alerts
    • Subscribe your email
    • Configure alarms to send to SNS
  4. CloudWatch Logs Insights:

    • Write query to find all error logs from last hour
    • Write query to count requests per minute

Deliverable

  • Dashboard name and screenshot
  • List of alarms with thresholds
  • Screenshot of email alert (trigger test alarm)
  • CloudWatch Logs Insights queries

Task 6: Security and IAM (15 points)

Objective

Implement security best practices.

Requirements

  1. IAM Roles:

    • EC2 role for Auto Scaling instances (SSM, CloudWatch)
    • CodeBuild service role
    • ECS task execution role
    • ECS task role
  2. Security Groups:

    • ALB security group (allow HTTP from internet)
    • Application security group (allow traffic only from ALB)
    • Document all rules
  3. S3 Bucket for Artifacts:

    • Encrypted at rest
    • Versioning enabled
    • Block public access
    • Lifecycle policy to delete after 30 days
  4. Secrets Manager:

    • Store a database password
    • Reference it in ECS task definition

Deliverable

  • IAM role policies (JSON)
  • Security group rules documentation
  • S3 bucket configuration
  • Secret ARN

Task 7: Disaster Recovery Test (20 points)

Objective

Implement and test backup and recovery procedures.

Requirements

  1. Create RDS Database:

    • MySQL or PostgreSQL
    • Multi-AZ deployment
    • Automated backups enabled (7-day retention)
    • In private subnets from Task 1
  2. Backup Strategy:

    • Take manual snapshot
    • Configure automated backup window
    • Copy snapshot to another region
  3. Recovery Test:

    • Restore database from snapshot to new instance
    • Document recovery time
    • Verify data integrity
  4. AMI Backup:

    • Create AMI from one Auto Scaling instance
    • Copy to another region
    • Launch instance from AMI in new region

Deliverable

  • RDS instance identifier
  • Snapshot ARNs (original and cross-region)
  • Recovery documentation with timestamps
  • AMI IDs in both regions

Task 8: Cost Optimization (15 points)

Objective

Analyze and optimize AWS costs.

Requirements

  1. Cost Explorer Analysis:

    • Enable Cost Explorer
    • Identify top 5 services by cost
    • Screenshot of cost breakdown
  2. Resource Tagging:

    • Tag all resources with:
      • Environment: dev
      • Project: devops-test
      • Owner: [your-name]
  3. Right-Sizing Recommendations:

    • Use AWS Compute Optimizer
    • Document recommendations for EC2 instances
  4. Budget and Alerts:

    • Create budget for $10/month
    • Set alert at 80% threshold

Deliverable

  • Cost report screenshot
  • List of all tagged resources
  • Right-sizing recommendations document
  • Budget configuration screenshot

Bonus Challenge (25 points)

Terraform Migration

Recreate Task 1 (VPC infrastructure) using Terraform instead of CloudFormation.

Requirements

  • main.tf with VPC, subnets, gateways
  • variables.tf for configurable parameters
  • outputs.tf for resource IDs
  • terraform.tfvars with values
  • Successfully apply and destroy

GitOps with GitHub Actions

Create a GitHub Actions workflow that:

  • Runs on push to main branch
  • Builds Docker image
  • Pushes to ECR
  • Updates ECS service

Submission Requirements

Create a document with:

  1. Architecture diagram showing all components
  2. Commands executed for each task
  3. Screenshots proving completion
  4. Code files (CloudFormation, scripts, Dockerfiles)
  5. Lessons learned and challenges faced
  6. Cost report of resources used

Cleanup Instructions

IMPORTANT: Delete all resources to avoid charges:

# Delete ECS service and cluster
aws ecs delete-service --cluster devops-cluster --service devops-service --force
aws ecs delete-cluster --cluster devops-cluster

# Delete Auto Scaling group
aws autoscaling delete-auto-scaling-group \
  --auto-scaling-group-name devops-asg --force-delete

# Delete Load Balancer
aws elbv2 delete-load-balancer --load-balancer-arn <arn>

# Delete CloudFormation stack
aws cloudformation delete-stack --stack-name devops-vpc-stack

# Delete RDS instance
aws rds delete-db-instance \
  --db-instance-identifier devops-db \
  --skip-final-snapshot

# Empty and delete S3 buckets
aws s3 rb s3://your-bucket-name --force

# Delete ECR repository
aws ecr delete-repository --repository-name devops-test-app --force

Evaluation Criteria

  • Functionality: Does it work as specified? (40%)
  • Best Practices: Follows AWS Well-Architected Framework? (25%)
  • Security: Proper IAM, encryption, network isolation? (20%)
  • Documentation: Clear, complete, reproducible? (15%)

Total Points: 190 (+ 25 bonus)

Good luck! This test will give you real, practical DevOps experience.

About

Some practice challenge generated by Claude

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published