Cloud and DevOps
AWS
The AWS services a backend engineer meets first, each with one diagram or table and its Google Cloud equivalent, ending in a reference design for a small bank API. No AWS account was used: every aws command that calls AWS is marked "Not run for this page". What was run: two local Python programs (their output is pasted), every JSON document was parsed, and every CLI flag was checked against the help text of aws-cli 2.31.8. Prices, quotas and limits are approximate; check the docs.
Accounts and regions
Part 1 of 6 · where things live and who pays
Sister pages: the same tour for Google Cloud and Azure.
Accounts and Organizations
An account is the hard wall: its own resources, its own IAM, its own bill. Teams use many accounts, grouped by an Organization, so that a mistake in dev cannot touch prod.
| AWS | What it is | GCP equivalent |
|---|---|---|
| Account | Isolation and billing unit, 12-digit id | Project |
| Organization, OU | Tree of accounts, one consolidated bill | Organization, folders |
| Service control policy (SCP) | Limits what any identity in an account can do. Grants nothing. | Organization Policy, deny policies |
| Root user | The email login that owns an account | No direct equivalent |
| IAM Identity Center | Single sign-on for people into many accounts | Cloud Identity, Workforce Identity |
Root user: turn on MFA, create no access keys, and do not use it for daily work. SCPs do not restrict the management account, so run no workloads there.
Regions and availability zones
A region is a separate copy of AWS in one geography. An availability zone (AZ) is one or more data centres with their own power and network. Spreading over AZs survives a building; spreading over regions survives a geography.
| Scope | Examples | GCP note |
|---|---|---|
| Global | IAM, Organizations, Route 53, CloudFront | IAM is global too |
| Regional | VPC, S3 bucket data, SQS, Lambda, DynamoDB, ECR | A GCP VPC is global, its subnets are regional |
| Zonal | Subnet, EC2 instance, EBS volume, NAT gateway | A GCP subnet spans all zones of its region |
Trap: AZ names are shuffled per account. Your 1a may be another account's 1b; compare AZ ids (aps1-az1) across accounts.
IAM
Part 2 of 6 · who can do what to which resource
Users, roles and policies
A user has long-lived credentials. A role has none: something assumes it and gets keys that expire. Prefer roles everywhere.
| AWS | What it is | GCP equivalent |
|---|---|---|
| IAM user | A person or script with a password or access keys | Google account, service account key |
| Role | An identity with no credentials of its own, assumed for a short time | Service account |
| Identity policy | JSON attached to a user, group or role: what it may do | Role binding on a resource |
| Resource policy | JSON on a bucket, queue or key: who may use it | Resource-level IAM policy |
| Trust policy | The resource policy of a role: who may assume it | serviceAccountUser, token creator |
| Permissions boundary | A ceiling on what an identity policy can grant | Deny policies, conditions |
Difference: in AWS a policy is attached to an identity and lists resources. In GCP a binding is attached to a resource and lists identities.
A policy document
IAM · JSON parsed, not applied to an account
The policy on the role the bank API runs as. Each statement is an effect, a list of actions and the exact resources. 111122223333 is the placeholder account id from the AWS docs.
| Least privilege habit | Why |
|---|---|
Name actions, not s3:* | A leaked key can then read, not delete |
Name resource ARNs, not "*" | One service cannot read another's bucket |
| One role per service | The blast radius is one service |
| Start from access denied, add what fails | IAM Access Analyzer can also draft a policy from CloudTrail history |
Conditions (aws:SourceVpce, aws:PrincipalOrgID) | Right identity from the wrong place is still refused |
How a request is decided
IAM · Python run locally
Everything starts denied. An explicit deny anywhere wins. Otherwise every layer that applies must allow.
The core rule for one policy, as a toy evaluator using the statements above. It is not the AWS engine: no conditions, no NotAction, one policy type.
Real check: aws iam simulate-principal-policy asks the real engine the same question (see the cheat sheet).
Assuming a role
IAM · JSON parsed, not applied
The caller asks STS for the role. STS checks the role's trust policy and returns keys that expire, by default after one hour.
| Where the code runs | How it gets the role | GCP equivalent |
|---|---|---|
| EC2 | Instance profile: a wrapper that attaches one role to the instance. Keys come from the metadata service (use IMDSv2). | Service account attached to the VM |
| ECS task | Task role (your code) and execution role (pull image, write logs, read secrets) | Cloud Run service identity |
| Lambda | Execution role | Function service account |
| EKS pod | Pod Identity or IRSA | Workload Identity |
| Another account | sts:AssumeRole on a role whose trust policy names your account | Service account impersonation |
| CI outside AWS | OIDC federation, AssumeRoleWithWebIdentity | Workload Identity Federation |
Rule: the SDK finds these credentials by itself. Access keys in environment files or images are the thing to remove.
Compute
Part 3 of 6 · where the code runs
Which compute
Pick the highest level that fits. Every step down buys control and costs operations work.
| Service | You manage | Billed by | GCP equivalent |
|---|---|---|---|
| EC2 | OS, patching, scaling groups | Instance second | Compute Engine |
| ECS on Fargate | Task definition only | vCPU and GB per second | Cloud Run |
| EKS | Kubernetes objects, add-ons, upgrades | Cluster hour plus nodes | GKE |
| Lambda | A function | Requests and GB-seconds | Cloud Run functions |
Rough guide: Fargate costs more per vCPU than EC2, and Lambda more than Fargate at steady high load. Low or spiky traffic reverses that order.
ECS, Fargate and ECR
Compute · Not run for this page
ECR stores the image. A task definition says how to run it, and a service keeps N copies running behind a load balancer.
| ECS word | Meaning | Kubernetes word |
|---|---|---|
| Cluster | A named group of capacity | Cluster |
| Task definition | Versioned recipe: image, CPU, memory, roles, env, logs | Pod spec |
| Task | One running copy, with its own network interface on Fargate | Pod |
| Service | Keeps N tasks healthy, rolls out new revisions, registers them with the ALB | Deployment plus Service |
| ECR repository | Private image registry, scan on push, lifecycle rules for old tags (GCP: Artifact Registry) | Image registry |
Tags: deploy an immutable tag (the commit) or a digest, never latest. Turn on tag immutability on the repository. Image building is covered in Docker.
Lambda
A function that AWS runs when an event arrives, scaled by running more copies. The first call on a new copy pays a cold start.
| Trigger type | Examples | On failure |
|---|---|---|
| Synchronous | API Gateway, ALB, function URL | The caller gets the error |
| Asynchronous | S3 event, SNS, EventBridge | Two retries, then a failure destination or DLQ if configured |
| Polled (event source mapping) | SQS, Kinesis, DynamoDB Streams | The batch returns to the source and is retried |
| Limit (approximate, check the docs) | Value |
|---|---|
| Timeout | 15 minutes |
| Memory | 128 MB to about 10 GB; CPU scales with it |
| Synchronous request and response | About 6 MB |
| Package | 250 MB unzipped, or a container image up to 10 GB |
| Concurrent executions | 1,000 per region by default, a soft quota |
- Cut cold starts: small package, clients created outside the handler, provisioned concurrency, SnapStart where the runtime supports it.
- Lambda in front of a relational database opens a connection per copy. Use RDS Proxy or cap concurrency.
Storage, databases and messaging
Part 4 of 6 · S3, RDS, DynamoDB, SQS and SNS
S3 classes, lifecycle and versioning
Storage, databases and messaging · JSON parsed, not applied
S3 stores objects under keys in a bucket. The storage class trades price per GB against retrieval cost and speed, and a lifecycle rule moves objects down as they age.
| Class | Use for | Catch | GCP equivalent |
|---|---|---|---|
| Standard | Active data | Highest price per GB | Standard |
| Intelligent-Tiering | Unknown access pattern | Small monitoring fee per object | Autoclass |
| Standard-IA | Monthly access | Retrieval fee, 30-day minimum | Nearline |
| Glacier Instant Retrieval | Quarterly access, millisecond reads | 90-day minimum | Coldline |
| Glacier Flexible Retrieval | Backups | Minutes to hours to restore | Archive (reads are instant there) |
| Glacier Deep Archive | Compliance copies | About 12 hours to restore, 180-day minimum | Archive |
- Versioning keeps every overwrite, and a delete only adds a delete marker. It protects against mistakes and is required for replication.
- Old versions are billed in full. Always pair versioning with
NoncurrentVersionExpiration.
Presigned URLs
Storage, databases and messaging · Python run locally
The API signs a URL with its own credentials and hands it to the client, who talks to S3 directly. Signing is local arithmetic; S3 is not contacted until the client uses the URL.
What the SDK does, using the example key pair and request published in the AWS Signature Version 4 docs. The last line confirms the result equals the signature printed there.
- In real code:
boto3generate_presigned_url, oraws s3 presign. Maximum lifetime is 7 days, and the URL dies earlier if the role session that signed it expires. - Anyone holding the URL has that one permission. Keep the lifetime in minutes.
- GCP equivalent: signed URLs on Cloud Storage.
Bucket policy and public access
Storage, databases and messaging · JSON parsed, not applied
A bucket policy is a resource policy. This one refuses plain HTTP for everyone and lets one role in an audit account (444455556666) read one prefix.
| Public-access mistake | Do this instead |
|---|---|
| Turning off Block Public Access to host a site or share a file | Keep it on at account level. Serve through CloudFront with origin access control, or presign. |
"Principal": "*" with Allow and no condition | Name the role, or add aws:PrincipalOrgID |
Granting s3:ListBucket to the world | Readers who know a key do not need to list |
| Object ACLs set to public-read | Leave ACLs disabled (the default for new buckets) |
| Presigned URLs valid for days, pasted in chats | Minutes, generated per request |
Encryption: objects are encrypted at rest by default (SSE-S3). Use a KMS key when you need to control or audit who can decrypt.
RDS and Aurora
Storage, databases and messaging
RDS runs PostgreSQL or MySQL for you: backups, patching, failover. Aurora is AWS's own storage layer under the same wire protocols.
| RDS | Aurora | |
|---|---|---|
| Storage | EBS volume per instance | Shared cluster volume, six copies over three AZs |
| Failover | About one to two minutes | Usually under a minute |
| Read replicas | A few, each with its own storage and lag | Up to 15, same storage, small lag |
| Cost | Lower at small size | Higher base, I/O priced separately unless I/O-Optimized |
| GCP equivalent | Cloud SQL | AlloyDB (Spanner for global writes) |
Both: point-in-time restore within the backup window (up to about 35 days) creates a new instance; it does not rewind the old one. Numbers approximate.
DynamoDB and ElastiCache
Storage, databases and messaging
| DynamoDB | ElastiCache | |
|---|---|---|
| What | Serverless key-value and document table | Managed Valkey, Redis OSS or Memcached |
| Access | By partition key, optional sort key, secondary indexes | By key, plus Redis data types |
| Pay for | Requests (on-demand) or provisioned capacity, plus storage | Node hours, or serverless usage |
| Good for | Idempotency keys, sessions, ledgers by account id | Cache, rate limits, locks |
| Bad for | Ad hoc queries and joins; items over about 400 KB | The only copy of data |
| GCP equivalent | Firestore, Bigtable | Memorystore |
DynamoDB rule: list the queries first, then design the keys. Patterns for the cache are in Caching Strategies.
SQS: standard and FIFO
Storage, databases and messaging
A queue between the API and its workers. The API returns at once; workers pull at their own pace.
| Standard | FIFO (name ends .fifo) | |
|---|---|---|
| Delivery | At least once, duplicates possible | Duplicates removed within a 5-minute window |
| Order | Best effort | Strict inside one MessageGroupId |
| Throughput | Practically unlimited | About 300 calls per second per API action, more with batching or high-throughput mode |
| Use for | Emails, statements, anything idempotent | Transfers per account: group id = account id |
| Setting (from the CLI help) | Default | Range |
|---|---|---|
| Visibility timeout | 30 s | 0 to 12 hours |
| Retention | 4 days | 1 minute to 14 days |
| Maximum message size | 1 MiB | 1 KiB to 1 MiB |
| Receive wait (long polling) | 0 s | 0 to 20 s |
| Delay | 0 s | 0 to 15 minutes |
GCP equivalent: a Pub/Sub pull subscription, or Cloud Tasks. Queue patterns in depth: Task Queues.
Visibility timeout and dead-letter queue
Storage, databases and messaging · JSON parsed, not applied
Receiving does not remove a message, it hides it. The worker deletes it after success. If the worker dies, the message reappears when the timeout ends.
maxReceiveCount and waits where a person can look at it.- Handlers must be idempotent: at-least-once means a transfer message can arrive twice. Carry a transfer id and check it.
- Long jobs extend their own timeout with
ChangeMessageVisibility. - Give the DLQ the longest retention and an alarm on any visible message.
SNS and fan-out
Storage, databases and messaging
SNS pushes one published message to every subscriber. Put a queue per consumer behind the topic and each one gets its own copy, its own retries and its own DLQ.
GCP equivalent: Pub/Sub does both jobs: a topic with one subscription per consumer. Also: EventBridge routes events by content rules and suits many event types from many sources. Kinesis and MSK are ordered logs you can replay.
Networking
Part 5 of 6 · VPC, firewalls, load balancers
VPC, subnets and gateways
A VPC is a private address range in one region. A subnet is a slice of it in one AZ, and its route table decides whether it is public.
| Subnet | Route for 0.0.0.0/0 | Holds |
|---|---|---|
| Public | Internet gateway | Load balancers, NAT gateways |
| Private | NAT gateway | Tasks, instances, Lambda |
| Isolated | None | Databases, caches |
| AWS | What it does | GCP equivalent |
|---|---|---|
| Internet gateway | Two-way door for resources with public IPs | Default internet gateway route |
| NAT gateway | Outbound-only internet for private subnets, one per AZ | Cloud NAT |
| VPC endpoint | Private path to S3, SQS, ECR without NAT | Private Google Access, Private Service Connect |
Related: CIDR, routing and NAT themselves are in Linux Networking.
Security groups and NACLs
| Security group | Network ACL | |
|---|---|---|
| Attached to | A network interface (task, instance, RDS, ALB) | A subnet |
| State | Stateful: replies are allowed automatically | Stateless: allow the return ports too |
| Rules | Allow only | Allow and deny |
| Evaluation | All rules together | By rule number, first match wins |
| Source can be | CIDR or another security group | CIDR only |
Chain groups by reference, not by IP: the database group allows 5432 only from the task group, and the task group allows 8000 only from the ALB group.
GCP equivalent: VPC firewall rules. They are stateful, support allow and deny with priorities, and target tags or service accounts.
ALB and NLB
| Application LB | Network LB | |
|---|---|---|
| Layer | 7: HTTP, HTTPS, gRPC, WebSocket | 4: TCP, UDP, TLS |
| Routes by | Host, path, header, method | Port |
| Address | DNS name, IPs change | One static IP per AZ |
| Client IP | In X-Forwarded-For | Preserved at the socket |
| Extras | WAF, redirects, OIDC login, Lambda targets | Very high throughput, PrivateLink |
| Use for | The bank API | Databases, MQTT, anything not HTTP, fixed IP allow-lists |
| GCP equivalent | Application Load Balancer | Network Load Balancer |
- Targets sit in a target group with a health check. A failing target stops receiving traffic.
- Set the deregistration delay and handle
SIGTERMso deploys do not drop requests. - Algorithms and health checks in depth: Nginx and Load Balancing.
Operate and design
Part 6 of 6 · watch it, keep its secrets, pay for it
CloudWatch
| Part | What it holds | GCP equivalent |
|---|---|---|
| Logs | Log groups of streams. Retention is "never expire" until you set it. | Cloud Logging |
| Metrics | Numbers by namespace and dimensions, one-minute by default | Cloud Monitoring |
| Alarms | A metric against a threshold: OK, ALARM, INSUFFICIENT_DATA. Actions go to SNS or auto scaling. | Alerting policies |
| CloudTrail (separate service) | Who called which AWS API, and when | Cloud Audit Logs |
| Alarm for the bank | Metric |
|---|---|
| API errors | ALB HTTPCode_Target_5XX_Count |
| API slow | ALB TargetResponseTime, p99 |
| Workers falling behind | SQS ApproximateAgeOfOldestMessage |
| Poison messages | DLQ ApproximateNumberOfMessagesVisible above 0 |
| Database filling | RDS FreeStorageSpace, DatabaseConnections |
Related: what to measure and how to set thresholds is in Observability.
Secrets Manager and Parameter Store
| Secrets Manager | Parameter Store (SSM) | |
|---|---|---|
| For | Database passwords, API keys | Config values, feature flags, some secrets |
| Rotation | Built in, managed for RDS | None; do it yourself |
| Size | About 64 KB | 4 KB standard, 8 KB advanced |
| Price (approximate) | About $0.40 per secret per month plus API calls | Standard tier free |
| GCP equivalent | Secret Manager | Parameter Manager |
- ECS injects either one as an environment variable through
secretsin the task definition (see below). The execution role needs read access. - An injected value is read at task start. After a rotation, restart tasks or fetch the secret in code with a short cache.
Cost control
Operate and design · all prices approximate, us-east-1, check the docs
| Tool | What it does | GCP equivalent |
|---|---|---|
| Tags | service, env, team on everything. Activate them as cost allocation tags or they do not appear on the bill. | Labels |
| Budgets | Alert on actual or forecast spend. An alert does not stop spending. | Billing budgets |
| Savings Plans | Commit to dollars per hour for 1 or 3 years. Compute plans cover EC2, Fargate and Lambda. | Committed use discounts |
| Spot | Spare capacity at a deep discount, reclaimed with two minutes' notice | Spot VMs |
| Bill surprise | Why | Fix |
|---|---|---|
| NAT gateway | About $0.045 per hour each, plus about $0.045 per GB through it | VPC endpoints for S3, ECR, SQS, logs; one NAT in non-prod |
| Data transfer out | About $0.09 per GB to the internet | CloudFront, compression |
| Cross-AZ traffic | About $0.01 per GB each way | Keep chatty services in the same AZ where safe |
| CloudWatch Logs | Ingestion per GB, kept forever by default | Set retention, drop debug logs |
| Public IPv4 | Every address is billed per hour | Private subnets behind one ALB |
| Idle resources | Unattached EBS volumes, old snapshots, forgotten load balancers | Tag, then review untagged spend |
| S3 leftovers | Old versions and incomplete multipart uploads | The lifecycle rule |
Order of work: tag, look at Cost Explorer, delete idle things, right-size, and only then commit to a Savings Plan.
Reference architecture
Operate and design · a design, not deployed; JSON keys checked against the CLI skeleton
The bank API: transfers are accepted by the API, queued, and applied by workers inside a database transaction.
| Decision | Reason |
|---|---|
| Fargate, two AZs, at least two tasks each | No hosts to patch; survives one AZ |
| Queue between API and ledger | Spikes are absorbed; a worker crash loses nothing |
| Transfer id as idempotency key, unique in the database | SQS can deliver twice |
| Balance change in one SQL transaction | The database, not the queue, guards the money |
| Task role and execution role separate | App code cannot pull images or read other secrets |
In practice: all of this is written as Terraform or CloudFormation, not clicked. On GCP the same shape is Cloud Run, Cloud SQL, Pub/Sub and Cloud Storage.
CLI cheat sheet
Operate and design · Not run for this page; flags checked against aws help
Every command takes --profile, --region, --output json|table|text and --query (a JMESPath filter).
| Task | Command |
|---|---|
| Who am I | aws sts get-caller-identity |
| Set up and log in with SSO | aws configure sso, then aws sso login --profile bank-dev |
| Would this be allowed | aws iam simulate-principal-policy --policy-source-arn ROLE_ARN --action-names s3:GetObject --resource-arns OBJECT_ARN |
| List, copy, sync | aws s3 ls s3://bank-statements/, aws s3 cp f.pdf s3://bank-statements/, aws s3 sync ./out s3://bank-statements/out --delete |
| Presign for 5 minutes | aws s3 presign s3://bank-statements/a.pdf --expires-in 300 |
| Block public access | aws s3api put-public-access-block --bucket bank-statements --public-access-block-configuration BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true |
| Roll an ECS service | aws ecs update-service --cluster bank --service bank-api --force-new-deployment |
| Shell into a task | aws ecs execute-command --cluster bank --task TASK_ID --container api --interactive --command /bin/sh |
| Follow logs | aws logs tail /ecs/bank-api --follow --since 10m |
| Queue depth | aws sqs get-queue-attributes --queue-url URL --attribute-names ApproximateNumberOfMessages |
| Redrive a DLQ | aws sqs start-message-move-task --source-arn DLQ_ARN |
| Read a secret | aws secretsmanager get-secret-value --secret-id bank/db --query SecretString --output text |
| Spend by service | aws ce get-cost-and-usage --time-period Start=2026-11-01,End=2026-12-01 --granularity MONTHLY --metrics UnblendedCost --group-by Type=DIMENSION,Key=SERVICE |
Interview questions
| Question | Short answer |
|---|---|
| User versus role? | A user has long-lived credentials. A role is assumed and yields temporary ones. Workloads and people should both use roles. More |
| An identity policy allows it and the call is denied. Why? | An explicit deny somewhere, an SCP, a permissions boundary, a missing resource policy across accounts, or a KMS key policy. More |
| Task role versus execution role? | Execution role: ECS pulls the image, writes logs, reads secrets. Task role: what your code may call. More |
| Lambda or Fargate for an API? | Lambda for spiky or low traffic and short work. Fargate for steady load, long requests, many database connections. More |
| Let a browser upload a 2 GB file? | Presigned PUT or multipart URLs straight to S3; the API only signs and records. More |
| Multi-AZ versus read replica? | Multi-AZ is a synchronous standby for failover. A replica is asynchronous, for read scale, and can lag. More |
| How do you avoid applying a transfer twice from SQS? | Idempotent handler: unique transfer id in the database, checked in the same transaction. FIFO narrows duplicates but does not remove the need. More |
| SQS, SNS or both? | SQS for one consumer group and buffering. SNS to copy an event to many. Fan-out is SNS into one queue per consumer. More |
| Security group versus NACL? | Stateful allow-list on an interface, versus stateless ordered allow and deny on a subnet. More |
| The bill doubled. Where do you look? | Cost Explorer by service and usage type: NAT gateway bytes, data transfer, log ingestion, idle resources. More |
Back to Cloud and DevOps. Next: Google Cloud and Azure.