AWS Documentation
The biggest cloud — IAM, EC2, S3, RDS, Lambda, VPC and CloudFront with the console and the AWS CLI.
Amazon Web Services (AWS) is the largest cloud platform: you rent servers, storage, databases and hundreds of other services by the hour or by the request instead of buying hardware. This guide covers the core services every developer meets — IAM, EC2, S3, RDS, Lambda, VPC, CloudFront, Route 53 — using the console and the AWS CLI.
1. Introduction & Setup
Key ideas:
| Term | Meaning |
|---|---|
| Region | a geographic area, e.g. ap-south-1 (Mumbai), us-east-1 (N. Virginia) |
| Availability Zone (AZ) | one or more separate data centres inside a region (ap-south-1a, 1b, 1c) |
| Edge location | CDN points of presence for CloudFront |
| Shared responsibility | AWS secures the cloud (hardware, facilities); you secure what you put in it (data, IAM, patches) |
Service models: IaaS (EC2 — you manage the OS), PaaS (Elastic Beanstalk, RDS — AWS manages the platform), SaaS, and serverless (Lambda — no servers to manage).
Getting started:
- Create an account (a card is needed; the Free Tier covers small usage).
- Turn on MFA for the root user, then stop using root.
- Create a budget alert (Billing → Budgets → e.g. $5/month) so you're warned before spending.
- Create an IAM user or use IAM Identity Center for daily work.
- Install the CLI and log in:
aws --version
aws configure # access key, secret, region (ap-south-1), output (json)
aws sts get-caller-identity
Output:
{
"UserId": "AIDAEXAMPLE123",
"Account": "123456789012",
"Arn": "arn:aws:iam::123456789012:user/asha"
}
⚠️ Never commit access keys to Git. Leaked keys are found by bots within minutes and used to mine crypto on your bill. Prefer IAM roles and short-lived credentials (
aws configure sso).
2. IAM — Identity & Access Management
IAM controls who can do what on which resources.
| Concept | Meaning |
|---|---|
| User | a person or app with long-term credentials |
| Group | a set of users sharing permissions |
| Role | an identity that is assumed temporarily — by EC2, Lambda, other accounts or SSO users |
| Policy | a JSON document of permissions |
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["s3:GetObject", "s3:PutObject"],
"Resource": "arn:aws:s3:::codify-uploads/*"
}
]
}
Rules:
- Least privilege: grant only what's needed.
- By default everything is denied; an explicit
Denyalways wins overAllow. - Give EC2/Lambda a role, not access keys.
- Enable MFA; rotate or avoid long-term keys.
3. EC2 — Virtual Servers
EC2 (Elastic Compute Cloud) gives you virtual machines ("instances").
| Choice | Examples |
|---|---|
| AMI (image) | Ubuntu 24.04, Amazon Linux 2023, Windows |
| Instance type | t3.micro (2 vCPU burst, 1 GiB — free tier eligible), t3.medium, m7i.large, c7g (Graviton/ARM) |
| Key pair | SSH key to log in |
| Security group | a stateful firewall for the instance |
| EBS volume | the instance's disk |
Launch and connect:
aws ec2 run-instances --image-id ami-0abcdef1234567890 --instance-type t3.micro \
--key-name codify-key --security-group-ids sg-0123abcd --count 1
chmod 400 codify-key.pem
ssh -i codify-key.pem ubuntu@<public-ip>
Security group example (inbound): SSH 22 from your IP only, HTTP 80 and HTTPS 443 from 0.0.0.0/0.
Pricing models:
| Model | Use |
|---|---|
| On-Demand | pay per second, no commitment |
| Savings Plans / Reserved | 1–3 year commitment, up to ~70% cheaper |
| Spot | spare capacity, up to ~90% cheaper, can be interrupted |
Scaling: an Auto Scaling Group keeps N instances healthy and adds/removes them based on CPU or requests, behind an Application Load Balancer.
Deploying a Node app on EC2 quickly: install Node (nvm), clone the repo, run with PM2 or systemd, put Nginx in front as a reverse proxy, and add HTTPS with Certbot. See Linux.
⚠️ Common error:
ssh: connect to host … port 22: Connection timed out— the security group doesn't allow port 22 from your IP, or the instance has no public IP.
4. S3 — Object Storage
S3 (Simple Storage Service) stores files ("objects") in buckets — unlimited size, 11 nines of durability. Used for uploads, backups, static websites, data lakes and logs.
aws s3 mb s3://codify-uploads-2026 # make bucket (globally unique name)
aws s3 cp avatar.png s3://codify-uploads-2026/avatars/ # upload
aws s3 ls s3://codify-uploads-2026/avatars/
aws s3 sync ./dist s3://codify-site --delete # deploy a static site
aws s3 rm s3://codify-uploads-2026/avatars/avatar.png
aws s3 presign s3://codify-uploads-2026/report.pdf --expires-in 3600 # temporary download link
| Storage class | For |
|---|---|
| S3 Standard | frequently accessed data |
| S3 Intelligent-Tiering | unknown access patterns |
| S3 Standard-IA / One Zone-IA | infrequent access |
| S3 Glacier (Instant / Flexible / Deep Archive) | archives — cheapest, slower retrieval |
- Block Public Access is on by default — keep it on; share files with pre-signed URLs or through CloudFront.
- Versioning keeps old versions; lifecycle rules move/delete objects automatically.
- Upload directly from the browser with a pre-signed PUT URL created by your backend (no file passes through your server):
import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3';
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
const s3 = new S3Client({ region: 'ap-south-1' });
const url = await getSignedUrl(
s3,
new PutObjectCommand({ Bucket: 'codify-uploads-2026', Key: `avatars/${userId}.png`, ContentType: 'image/png' }),
{ expiresIn: 300 }
);
// return url to the browser → fetch(url, { method: 'PUT', body: file })
5. Databases: RDS, DynamoDB & More
| Service | Type | Use |
|---|---|---|
| RDS | managed MySQL, PostgreSQL, MariaDB, SQL Server, Oracle | classic relational apps |
| Aurora | AWS's MySQL/Postgres-compatible engine | high performance, auto-growing storage |
| DynamoDB | serverless key-value / document NoSQL | massive scale, single-digit ms latency |
| ElastiCache | Redis / Memcached | caching, sessions |
| DocumentDB | MongoDB-compatible | document workloads |
RDS handles backups, patching, Multi-AZ failover (a standby in another AZ) and read replicas. Put databases in private subnets, allow access only from the app's security group.
aws rds describe-db-instances --query "DBInstances[].{id:DBInstanceIdentifier,engine:Engine,status:DBInstanceStatus}"
DynamoDB basics: a table has a partition key (and optional sort key); design tables around your queries.
aws dynamodb put-item --table-name Users --item '{"userId":{"S":"u1"},"name":{"S":"Asha"}}'
aws dynamodb get-item --table-name Users --key '{"userId":{"S":"u1"}}'
6. Lambda — Serverless Functions
Lambda runs your function when an event happens (HTTP request, S3 upload, queue message, schedule). No servers; you pay per request and per millisecond of execution.
// index.mjs
export const handler = async (event) => {
const name = event.queryStringParameters?.name ?? 'Coder';
return {
statusCode: 200,
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ message: `Hello, ${name}!` }),
};
};
- Expose it over HTTP with a Function URL or API Gateway.
- Limits: up to 15 minutes per run, 128 MB – 10 GB memory, configurable concurrency.
- Cold start: the first call after idle time is slower (setting up the runtime).
- Typical triggers: API Gateway, S3 (
ObjectCreated→ make a thumbnail), SQS, EventBridge schedules (cron), DynamoDB streams. - Tooling: AWS SAM, Serverless Framework, AWS CDK.
7. Networking: VPC, Load Balancers, Route 53 & CloudFront
VPC (Virtual Private Cloud) — your own private network in AWS.
VPC 10.0.0.0/16
├── Public subnet 10.0.1.0/24 (AZ a) ← load balancer, bastion; route 0.0.0.0/0 → Internet Gateway
├── Public subnet 10.0.2.0/24 (AZ b)
├── Private subnet 10.0.11.0/24 (AZ a) ← app servers; outbound via NAT Gateway
├── Private subnet 10.0.12.0/24 (AZ b)
└── Private DB subnets ← RDS, no internet route
| Piece | Job |
|---|---|
| Internet Gateway | connects public subnets to the internet |
| NAT Gateway | lets private instances reach out (updates) without being reachable |
| Route table | where traffic from a subnet goes |
| Security group | stateful firewall per instance/ENI (allow rules only) |
| Network ACL | stateless firewall per subnet (allow and deny) |
- Elastic Load Balancing: ALB (HTTP/HTTPS, path/host routing — layer 7), NLB (TCP/UDP, very fast — layer 4).
- Route 53: DNS — domains, A/AAAA/CNAME/alias records, health checks, latency/geo routing.
- CloudFront: CDN — caches content at edge locations; serve S3 sites and APIs fast with HTTPS.
- ACM (Certificate Manager): free TLS certificates for ALB and CloudFront.
8. Containers, Deployment & Infrastructure as Code
| Service | What |
|---|---|
| ECR | private Docker image registry |
| ECS | run containers (on Fargate — serverless — or EC2) |
| EKS | managed Kubernetes |
| Elastic Beanstalk | upload code; AWS creates EC2, LB and scaling for you |
| App Runner | container/source → HTTPS web service |
| Amplify | host front ends (React/Next.js) with CI/CD |
Push an image to ECR:
aws ecr get-login-password --region ap-south-1 | docker login --username AWS --password-stdin 123456789012.dkr.ecr.ap-south-1.amazonaws.com
docker tag codify-api:1.0 123456789012.dkr.ecr.ap-south-1.amazonaws.com/codify-api:1.0
docker push 123456789012.dkr.ecr.ap-south-1.amazonaws.com/codify-api:1.0
Infrastructure as Code — define resources in files, review them in Git, recreate environments reliably: CloudFormation (YAML/JSON), AWS CDK (TypeScript/Python), Terraform (multi-cloud).
9. Monitoring, Security & Cost
- CloudWatch: metrics (CPU, requests), logs (
/aws/lambda/<fn>), alarms (email/SNS when CPU > 80%), dashboards. - CloudTrail: an audit log of every API call — who did what, when.
- Secrets Manager / SSM Parameter Store: store DB passwords and API keys; apps read them at runtime with their IAM role.
- KMS: encryption keys; turn on encryption for S3, EBS and RDS.
- WAF & Shield: block common web attacks and DDoS.
- GuardDuty: threat detection.
Cost control:
- Set budgets and alerts on day one.
- Stop or terminate idle instances; delete unattached EBS volumes and old snapshots; release unused Elastic IPs.
- NAT Gateways and load balancers cost money even when idle.
- Use the Pricing Calculator before building and Cost Explorer after.
10. Advanced Concepts & Architecture
Well-Architected Framework — 6 pillars: operational excellence, security, reliability, performance efficiency, cost optimisation, sustainability.
A typical scalable web app on AWS:
Route 53 → CloudFront (static React from S3)
→ ALB (HTTPS, ACM) → Auto Scaling Group / ECS Fargate (API, private subnets, 2 AZs)
→ RDS Multi-AZ (private) + ElastiCache Redis
→ S3 (uploads via pre-signed URLs)
SQS queue → Lambda workers (emails, thumbnails)
CloudWatch logs/alarms · Secrets Manager · IAM roles everywhere
- High availability: spread across at least two AZs; disaster recovery: backups and cross-region replication.
- Messaging: SQS (queues), SNS (pub/sub notifications), EventBridge (event bus, schedules), Kinesis (streaming).
- Certifications path: Cloud Practitioner → Solutions Architect Associate → Developer / SysOps Associate → Professional.
11. Examples with Output
Example 1 — List buckets
aws s3 ls
2026-10-01 10:12:44 codify-site
2026-10-03 18:40:02 codify-uploads-2026
Example 2 — Running instances as a table
aws ec2 describe-instances --filters Name=instance-state-name,Values=running \
--query "Reservations[].Instances[].[InstanceId,InstanceType,PublicIpAddress]" --output table
------------------------------------------------------
| DescribeInstances |
+----------------------+-----------+-----------------+
| i-0a1b2c3d4e5f67890 | t3.micro | 13.233.45.120 |
+----------------------+-----------+-----------------+
Example 3 — Invoke a Lambda function
aws lambda invoke --function-name hello --cli-binary-format raw-in-base64-out \
--payload '{"queryStringParameters":{"name":"Asha"}}' out.json && cat out.json
{"statusCode":200,"headers":{"Content-Type":"application/json"},"body":"{\"message\":\"Hello, Asha!\"}"}
12. Practice Problems
- Create an account safely: MFA on root, an admin IAM user/SSO, and a $5 budget alert.
- Host a React build as a static website on S3 behind CloudFront with HTTPS.
- Launch a
t3.microEC2 instance, SSH in, and run an Express API with PM2 and Nginx. - Give the EC2 instance an IAM role that can only read one S3 bucket; test with the CLI (no keys on the server).
- Implement avatar uploads with pre-signed S3 URLs from your Node backend.
- Write a Lambda function behind a Function URL that returns JSON, and view its logs in CloudWatch.
- Create an RDS PostgreSQL instance in a private subnet and connect from the EC2 app only.
- Recreate the same setup with Terraform or AWS CDK and destroy it when done.
13. Interview Questions
1. Region vs Availability Zone? A region is a geographic area; AZs are isolated data centres within it. Deploy across multiple AZs for high availability.
2. What is IAM and least privilege? IAM manages identities and permissions; least privilege means granting only the actions and resources required.
3. IAM user vs role? Users have long-term credentials; roles are assumed for temporary credentials by services, apps or federated users.
4. Security group vs NACL? Security groups are stateful, instance-level, allow-only; NACLs are stateless, subnet-level, with allow and deny rules.
5. S3 storage classes? Standard, Intelligent-Tiering, Standard-IA, One Zone-IA and Glacier tiers — trading cost against access speed and frequency.
6. EC2 vs Lambda? EC2 is a server you manage and pay for while it runs; Lambda runs code per event with no server management, billed per request and duration (max 15 minutes).
7. What is Auto Scaling? Automatically adjusting the number of instances based on demand or schedules, replacing unhealthy ones.
8. RDS Multi-AZ vs read replica? Multi-AZ is a synchronous standby for failover (availability); read replicas are asynchronous copies for scaling reads.
9. What does CloudFront do? A CDN that caches content at edge locations to reduce latency and load on the origin.
10. How do you secure an S3 bucket? Keep Block Public Access on, use bucket policies/IAM least privilege, enable encryption and versioning, and share via pre-signed URLs or CloudFront.
14. Cheat Sheet & References
Setup and identity
aws configure
aws configure sso
aws sts get-caller-identity
aws iam list-users
export AWS_PROFILE=dev
S3
aws s3 mb s3://bucket-name
aws s3 cp file.txt s3://bucket-name/path/
aws s3 sync ./dist s3://bucket-name --delete
aws s3 ls s3://bucket-name --recursive
aws s3 presign s3://bucket-name/file.pdf --expires-in 3600
aws s3 rb s3://bucket-name --force
EC2
aws ec2 describe-instances --output table
aws ec2 start-instances --instance-ids i-123
aws ec2 stop-instances --instance-ids i-123
aws ec2 terminate-instances --instance-ids i-123
ssh -i key.pem ubuntu@<public-ip>
Lambda and logs
aws lambda list-functions
aws lambda invoke --function-name fn out.json
aws logs tail /aws/lambda/fn --follow
aws cloudwatch describe-alarms
Containers
aws ecr create-repository --repository-name app
aws ecr get-login-password | docker login --username AWS --password-stdin <acct>.dkr.ecr.<region>.amazonaws.com
aws ecs list-clusters
aws eks update-kubeconfig --name my-cluster
Official documentation