Batch 4: Cloud Ansible AWS & Azure Docker & Podman Apache & NGINX ← Full TOC

← AWS Index

🟠 AWS Core Services — EC2, S3, RDS, Lambda, IAM, VPC — essential AWS

AWS (Amazon Web Services) is the world's largest cloud provider. These core services cover compute, storage, database, networking, and identity — mastering them handles 80% of real-world AWS work.

📋 Reference

ItemSyntaxDescription
EC2Elastic Compute Cloud — virtual machinest3.micro free tier, m5.large general, c5.xlarge compute-optimized
AMIAmazon Machine Image — OS snapshotami-0c55b159cbfafe1f0 = Ubuntu 20.04
S3Simple Storage Service — object storageUnlimited scale, 11 9s durability, $0.023/GB/month
S3 bucket policiesJSON policy on bucketControl access — public read, cross-account, etc.
RDSRelational Database Service — managed DBMySQL, PostgreSQL, Oracle, SQL Server, MariaDB
RDS Multi-AZAutomatic failover to standbyProduction must use Multi-AZ — automatic failover <2 min
AuroraMySQL/PostgreSQL-compatible, 5x faster than MySQLAuto-scales storage, up to 15 read replicas
DynamoDBServerless NoSQL — single-digit ms at any scaleOn-demand or provisioned, Global Tables for multi-region
LambdaServerless functions — event-driven compute15 min timeout, 10GB memory, pay per 100ms
API GatewayManaged REST/HTTP/WebSocket APIIntegrates with Lambda for serverless APIs
CloudFrontGlobal CDN — cache content at 400+ edge locationsReduce latency, absorb DDoS, free SSL with ACM
Route 53Authoritative DNS + health checks + routing policiesLatency, weighted, failover, geolocation routing
VPCVirtual Private Cloud — isolated networkYour own network: subnets, route tables, gateways
ELBElastic Load Balancing — ALB/NLB/CLBALB = Layer 7 (HTTP/S), NLB = Layer 4 (TCP/UDP)
Auto ScalingScale EC2/ECS/Lambda automaticallyTarget tracking: keep CPU at 60%, scale in/out
ECSElastic Container Service — managed DockerFargate (serverless) or EC2 launch type
EKSElastic Kubernetes Service — managed KubernetesRun k8s without managing control plane
ECRElastic Container Registry — private Docker registryIntegrated with ECS, EKS, and CodeBuild
IAMIdentity and Access ManagementUsers, groups, roles, policies — least privilege always
CloudFormationInfrastructure as Code with JSON/YAML templatesStack = group of AWS resources, change sets for updates
SQSSimple Queue Service — message queuingDecouple services, retry on failure, FIFO or standard
SNSSimple Notification Service — pub/sub messagingFan-out: one message to email, SMS, SQS, Lambda
ElastiCacheManaged Redis or MemcachedCache DB queries, sessions, real-time leaderboards
Secrets ManagerStore and auto-rotate credentialsRDS passwords, API keys — never hardcode credentials
CloudWatchMetrics, logs, alarms, dashboardsMonitor everything — set alarms for all critical metrics
CloudTrailAPI audit log — all AWS callsEnable in all regions — required for compliance

💡 Example

# AWS CLI — Essential Commands
# Setup: pip install awscli && aws configure

# ── EC2 ──────────────────────────────────────────────────────
# Launch Ubuntu instance
aws ec2 run-instances \
  --image-id $(aws ec2 describe-images \
    --owners 099720109477 \
    --filters "Name=name,Values=ubuntu/images/hvm-ssd/ubuntu-*22.04*amd64*" \
    --query 'sort_by(Images,&CreationDate)[-1].ImageId' --output text) \
  --instance-type t3.micro \
  --key-name MyKeyPair \
  --security-group-ids sg-xxxxxxxx \
  --subnet-id subnet-xxxxxxxx \
  --tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=WebServer}]'

# List, stop, start, terminate
aws ec2 describe-instances --query 'Reservations[].Instances[].[InstanceId,State.Name,PublicIpAddress,Tags[?Key==`Name`].Value|[0]]' --output table
aws ec2 stop-instances     --instance-ids i-xxxxxxxxxxxxxxxxx
aws ec2 start-instances    --instance-ids i-xxxxxxxxxxxxxxxxx
aws ec2 terminate-instances --instance-ids i-xxxxxxxxxxxxxxxxx

# ── S3 ───────────────────────────────────────────────────────
aws s3 mb s3://mywebuniversity-$(date +%s)
aws s3 cp index.html s3://mybucket/
aws s3 sync ./html/ s3://mybucket/ --delete
aws s3 ls s3://mybucket/ --recursive --human-readable
aws s3 rm s3://mybucket/old-file.html

# Static website hosting
aws s3 website s3://mybucket --index-document index.html
aws s3api put-bucket-policy --bucket mybucket --policy '{
  "Version":"2012-10-17",
  "Statement":[{"Effect":"Allow","Principal":"*","Action":"s3:GetObject","Resource":"arn:aws:s3:::mybucket/*"}]}'

# ── RDS ──────────────────────────────────────────────────────
aws rds create-db-instance \
  --db-instance-identifier mywebuniversity-db \
  --db-instance-class db.t3.micro \
  --engine postgres \
  --master-username admin \
  --master-user-password SecurePass123! \
  --allocated-storage 20 \
  --vpc-security-group-ids sg-xxxxxxxx \
  --backup-retention-period 7 \
  --multi-az \
  --no-publicly-accessible

aws rds describe-db-instances --query 'DBInstances[].[DBInstanceIdentifier,DBInstanceStatus,Endpoint.Address]' --output table

# ── Lambda ───────────────────────────────────────────────────
zip function.zip lambda_function.py
aws lambda create-function \
  --function-name mywebuniversity-api \
  --runtime python3.12 \
  --role arn:aws:iam::123456789012:role/lambda-role \
  --handler lambda_function.lambda_handler \
  --zip-file fileb://function.zip \
  --timeout 30 --memory-size 256

aws lambda invoke \
  --function-name mywebuniversity-api \
  --payload '{"path":"/courses"}' \
  --cli-binary-format raw-in-base64-out response.json
cat response.json

# ── IAM ──────────────────────────────────────────────────────
aws iam create-role --role-name LambdaExecutionRole \
  --assume-role-policy-document '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"Service":"lambda.amazonaws.com"},"Action":"sts:AssumeRole"}]}'
aws iam attach-role-policy --role-name LambdaExecutionRole \
  --policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole

# ── CloudFormation ────────────────────────────────────────────
aws cloudformation deploy \
  --template-file template.yaml \
  --stack-name mywebuniversity \
  --capabilities CAPABILITY_IAM \
  --parameter-overrides Environment=production
aws cloudformation describe-stacks --stack-name mywebuniversity

🏠 Index  |  Azure Core Services →