Part 3 Exercises: Cloud Platforms
Test your understanding of AWS, GCP, Azure, and simpler deployment platforms.
How to use these exercises
Read each question carefully. Try to answer it in your own words before revealing the answer. If you can explain a concept out loud β to a friend, to your rubber duck, to the wall β you understand it. If you stumble, re-read the relevant section in the chapter. There are no shortcuts: genuine understanding beats memorized answers every time.
Question: What is the AWS equivalent of Google Cloud's Cloud Run? Describe what Cloud Run does, and explain why there might be more than one AWS service that partially matches it.
Answer: Exercise 1
Cloud Run runs Docker containers in a serverless, fully managed environment β you give it an image, it deploys it with a public HTTPS URL, scales to zero when there's no traffic, and scales up automatically under load. You pay per request, not per idle server.
The closest AWS equivalent is AWS Fargate β specifically Fargate running on ECS (Elastic Container Service) or EKS. Like Cloud Run, Fargate runs Docker containers without you managing the underlying EC2 instances. However, it does not scale to zero by default β you need additional configuration for that.
AWS Lambda is the serverless scale-to-zero service, but it runs code functions, not arbitrary Docker containers (though Lambda does support container images up to 10GB as of 2020). Lambda has a 15-minute execution time limit; Cloud Run supports requests up to 60 minutes.
AWS App Runner (launched 2021) is the closest conceptual match: give it a container image, and it deploys it with automatic scaling, HTTPS, and minimal configuration β virtually identical to the Cloud Run developer experience.
Cloud Run β AWS App Runner (closest match)
Cloud Run β AWS Fargate on ECS (no scale-to-zero by default)
Cloud Run β AWS Lambda Container Images (for function-style workloads)
Question: Your app needs to store 10,000 profile photos uploaded by users. Each photo is between 50KB and 2MB. Which AWS service do you use, and why? What would a typical file path look like?
Answer: Exercise 2
Use Amazon S3 (Simple Storage Service).
S3 is purpose-built for exactly this use case β storing large numbers of user-uploaded files (objects). Here is why it is the right choice:
- Scale: S3 has no limit on the number of objects. 10,000 photos today, 10 million photos in two years β no migration required.
- Durability: 99.999999999% (eleven nines). Your photos are automatically replicated across multiple data centers in the region.
- Cost: approximately $0.023/GB/month. 10,000 photos averaging 500KB each = ~5GB = ~$0.12/month.
- Direct upload: users can upload directly to S3 via pre-signed URLs, bypassing your server entirely (reduces bandwidth costs on your API).
- CDN integration: attach CloudFront to serve photos from edge locations near each user β fast load times globally.
A typical S3 object structure for profile photos:
s3://my-app-uploads/
βββ users/
βββ u_1234/
β βββ profile/
β βββ original.jpg β full-size original
β βββ thumb_200x200.jpg β resized thumbnail
β βββ thumb_50x50.jpg β tiny avatar
βββ u_5678/
β βββ profile/
β βββ original.png
β βββ thumb_200x200.jpg
βββ ...
Use the user's unique ID (not username β usernames can change) as the folder name. Store the S3 key (path) in your database, not the full URL β the URL structure can change if you move buckets or add CloudFront.
Question: Explain what IAM is and why it is important. Describe the difference between an IAM user, an IAM role, and an IAM policy, using a non-technical analogy.
Answer: Exercise 3
IAM (Identity and Access Management) is AWS's system for controlling who can do what to which resources. Before any AWS API call succeeds β whether it comes from your CLI, your application code, a Lambda function, or an EC2 instance β IAM checks: "Is this entity authorized to perform this action on this resource?"
IAM is critically important because without it, anyone with your AWS credentials could access everything β read your database, delete your S3 files, create thousands of EC2 instances and run up a huge bill. IAM lets you grant only the minimum permissions needed for each user or service. This is called the principle of least privilege.
Imagine a large office building (your AWS account).
IAM Policy: a written rulebook that says "people with this badge can
enter floors 1β3 and the server room, but not the CEO's office or the finance floor."
IAM User: an individual employee with a physical badge (credentials β
an access key and secret). Alice the developer has her own badge with her own access
level.
IAM Role: a temporary visitor badge given to a contractor or a
delivery person. The EC2 server (the delivery person) picks up a role badge when it
needs to access the storage room (S3). The badge has an expiry and rotates automatically.
Unlike a user's badge, no one carries it around permanently β it's picked up and
returned.
Key practical rules:
- Never use root credentials for daily work β lock them away, enable MFA.
- Use roles (not hardcoded credentials) for EC2 instances, Lambda functions, and ECS tasks. Roles rotate automatically; hardcoded credentials get leaked.
- Grant only the permissions actually needed. An app that only reads from one S3 bucket should have a policy that only allows
s3:GetObjecton that one bucket.
Question: What does "serverless" mean in the context of cloud computing? Name the serverless function service on each of the three major clouds. What are the advantages and disadvantages of serverless?
Answer: Exercise 4
"Serverless" does not mean there are no servers β it means you don't manage any servers. The cloud provider handles provisioning, scaling, patching, and availability entirely. From your perspective, you write a function, deploy it, and it runs. You pay per invocation and per millisecond of execution, not per hour of idle server.
Serverless Functions on Each Cloud
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Cloud Service Trigger types
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
AWS Lambda HTTP (API Gateway), S3,
DynamoDB, SQS, EventBridge,
scheduled (cron), Kinesis
GCP Cloud Functions HTTP, Pub/Sub, Cloud Storage,
Firestore, scheduled (cron)
Azure Azure Functions HTTP, Blob Storage, Queue,
CosmosDB, Event Grid,
Service Bus, Timer (cron)
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Advantages of serverless:
- Zero idle cost: if no one calls your function, you pay nothing. Perfect for infrequent tasks.
- Automatic scaling: from 0 to 10,000 concurrent executions in seconds, no manual configuration.
- No infrastructure management: no OS patching, no capacity planning, no load balancer configuration.
- Event-driven architecture: naturally models workflows where code should run in response to things happening (file uploaded, record changed, message queued).
Disadvantages of serverless:
- Cold starts: if the function hasn't run recently, the first invocation takes 100β500ms extra while the container spins up. Bad for latency-sensitive endpoints.
- Execution time limits: Lambda has a 15-minute maximum. Long-running jobs need a different solution.
- Debugging is harder: you can't SSH into the server; you have to rely on logs and traces.
- Vendor lock-in: serverless code is often tightly coupled to the cloud provider's event model.
- Cost at high volume: for continuously high traffic, a permanently running server may actually be cheaper than paying per invocation.
Question: You have just built a Next.js application. It has a few API routes that connect to a PostgreSQL database. Which deployment platform would you start with, and why? At what point would you consider migrating to something more complex?
Answer: Exercise 5
Start with Vercel for the Next.js app and Supabase or Render for the PostgreSQL database.
Why Vercel: Vercel was built by the creators of Next.js. It auto-detects the framework, sets correct build settings automatically, handles server components and edge functions natively, and deploys to a global CDN with SSL in seconds. There is zero infrastructure configuration. Every pull request gets a preview URL. Rollbacks are instant. The free tier covers most early-stage projects.
Why not AWS immediately: For a Next.js app, running it on AWS ECS or EC2 means configuring an Application Load Balancer, ECR for the container image, ECS task definitions, VPC networking, security groups, and IAM roles β hours of work that adds no value to your product at this stage.
Early-Stage Architecture (Zero cost, 15 minutes to set up) ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ Vercel (free) β Next.js frontend + API routes Supabase free tier β PostgreSQL database (500MB) Vercel Blob / Cloudinary β File uploads (photos, etc.) When to migrate: ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ 10,000+ daily users β Consider Render or Railway for API DB > 500MB β Upgrade Supabase or move to Render DB Custom networking req. β Move to AWS/GCP Compliance requirements β Move to managed cloud with audit logs WebSocket connections β Move backend to Render or Railway
Question: Explain the difference between EC2 and Lambda. Give a concrete example of a workload that is best suited to EC2, and a different workload that is best suited to Lambda.
Answer: Exercise 6
EC2 vs Lambda β Core Differences
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
EC2 Lambda
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
What is it? Virtual machine Event-driven function
Management You manage OS, updates Fully managed by AWS
Billing Per hour (or second) Per invocation + duration
State Persistent (files stay) Ephemeral (no disk state)
Runtime Anything you install Node.js, Python, Java,
Go, Ruby, .NET, custom
Max runtime Unlimited 15 minutes
Cold start None (always running) 100β500ms first invoke
Concurrency You scale manually Automatic (up to 1000s)
Networking Full VPC control Limited (configurable)
SSH access Yes No
Cost when idle Full price $0
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Best for EC2: A long-running Node.js API server that handles persistent WebSocket connections from thousands of concurrent users. WebSocket connections are stateful and long-lived β they don't fit the request/response Lambda model. You need a persistent process running on a real server.
Best for Lambda: An image resizing function that triggers whenever a user uploads a photo to S3. The function needs to run for a few seconds, resize the image to three thumbnail sizes, and store the results back in S3. It might run 100 times per day or 10,000 times per day. With Lambda, you pay for 10,000 invocations at a fraction of a cent each; with EC2, you pay 24/7 for an idle server waiting for uploads.
Question: Your company runs Windows Server 2022, Active Directory for employee authentication, SQL Server for databases, and everyone uses Microsoft 365 (Teams, Outlook, SharePoint). Which cloud platform is the natural choice for your cloud migration? List three specific Azure services that directly benefit from this existing Microsoft investment.
Answer: Exercise 7
Azure is the natural choice, and by a significant margin.
Three Azure services that directly leverage the existing Microsoft investment:
- Microsoft Entra ID (formerly Azure Active Directory): your existing Active Directory can be synced to Entra ID via Azure AD Connect. Employees use their existing corporate credentials to log into cloud resources, SaaS apps, and Azure services β single sign-on across everything. This would require significant additional work to replicate on AWS (AWS Directory Service exists but is not native AD).
- Azure SQL Database: a fully managed version of SQL Server in the cloud. Migrate your on-premises SQL Server databases to Azure SQL with the Database Migration Service β minimal code changes. The SQL Server dialect, stored procedures, and T-SQL features you already use work natively. On AWS, you'd be moving to RDS SQL Server (more expensive) or rewriting queries for PostgreSQL/MySQL.
- Azure DevOps: integrates directly with the Microsoft 365 identity system (same login as Teams and Outlook). Connect pull request reviews to Teams channels. Link code commits to Azure Boards work items that appear in SharePoint dashboards. The entire development workflow lives in the same Microsoft ecosystem employees already use daily.
Many large companies have Enterprise Agreements with Microsoft for Office 365 and Windows Server licenses. These agreements often include Azure credits or significant discounts that make Azure substantially cheaper than equivalent AWS or GCP usage for companies already in the Microsoft ecosystem.
Question: What does a custom VPC provide that you don't get with a default AWS setup? Explain the purpose of a public subnet and a private subnet, and describe why a production database should always be in a private subnet.
Answer: Exercise 8
AWS does create a default VPC in every region so you can launch resources immediately, but the default VPC is configured for convenience, not security. Everything launched in the default VPC gets a public IP address by default and is reachable from the internet (subject to security groups). This is fine for experimentation, dangerous for production.
A custom VPC gives you:
- Full IP address range control: you define your private network (e.g.,
10.0.0.0/16) and divide it into subnets however you want. - Network segmentation: isolate databases, application servers, and load balancers into separate subnets with different access rules.
- Defense in depth: an attacker who compromises your web server can't directly reach your database if the database is in a private subnet with no route from the internet.
- Custom routing: precise control over which traffic goes where β through NAT Gateways, VPN connections, Direct Connect links, VPC peering.
Public vs Private Subnets ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ PUBLIC SUBNET: - Has a route to the Internet Gateway - Resources CAN have public IPs - Direct internet traffic in and out - Used for: Load Balancers, Bastion Hosts, NAT Gateways PRIVATE SUBNET: - NO route to the Internet Gateway - Resources get only private IPs (10.x.x.x range) - No direct inbound traffic from internet possible - Outbound internet via NAT Gateway (one-way) - Used for: App servers, Databases, Worker nodes ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Why the database should always be in a private subnet: Your PostgreSQL database contains your most valuable and sensitive data β user records, financial transactions, business data. If it were in a public subnet with a public IP, it would be reachable from the entire internet. Even with strong password requirements, an exposed database is a target for brute force attacks, vulnerability exploits, and data exfiltration. In a private subnet, the database is not reachable from the internet at all β the only way to connect is from within the same VPC (your application servers). The attack surface is dramatically reduced.
Question: Describe the fundamental difference between Vercel and cPanel in terms of the type of projects each serves, the kind of developer who uses each one, and the limitations you would hit if you tried to use each for the wrong project type.
Answer: Exercise 9
Vercel vs cPanel β A Complete Comparison
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Vercel cPanel
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Technology era Modern (2015+) Traditional (1996+)
Target user JavaScript devs PHP/WordPress devs
Frontend engineers Small business owners
JAMstack practitioners Designers/bloggers
Primary use case Next.js, React, Vue WordPress, PHP, Joomla
Static sites, SPAs Classic HTML/PHP sites
API routes (Node.js) Shared hosting plans
Deployment method Git push (GitHub/GitLab) FTP / File Manager
CLI: vercel --prod Softaculous one-click
Infrastructure Managed, serverless Shared Linux server
Edge network, global CDN Single data center
Docker support No No
Custom ports No No (only 80/443)
Database External (Supabase/PlanetScale) MySQL via phpMyAdmin
Node.js Yes (API routes, SSR) Limited (Passenger-based)
Scaling Auto, to millions Manual, shared CPU
Zero-config Contact hosting provider
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Wrong-fit limitations:
- Using Vercel for a WordPress site: Vercel doesn't run PHP. WordPress requires a PHP runtime and a MySQL database accessible to the server. You'd need to decouple WordPress into a "headless" setup (WordPress as a CMS, Vercel rendering the frontend) β a significant architectural change for no practical benefit at small scale.
- Using cPanel for a modern Node.js microservices app: cPanel's Node.js support is limited β it uses Passenger to proxy Node apps but doesn't support Docker, WebSockets reliably, or custom port exposure. Running multiple services, managing environment variables securely, or doing zero-downtime deployments is not practical. You'd hit these limits almost immediately.
Question: Large companies like Spotify, Netflix, and major banks typically use multiple cloud providers simultaneously rather than committing 100% to one. Describe at least four distinct reasons why a company might run workloads across AWS, GCP, and Azure rather than going "all in" on one provider.
Answer: Exercise 10
There are several distinct, legitimate reasons why large companies end up β or choose to be β on multiple clouds:
- Mergers and Acquisitions: Company A has been on AWS for five years. It acquires Company B, which has been on GCP. Migrating either company's entire infrastructure to the other cloud would take years and risk major outages. The faster, safer path is to leave each company's workloads where they are and build integration layers between the two environments. Many enterprise multi-cloud situations are born this way.
- Best-of-breed services: Google's BigQuery is genuinely better for large-scale analytical queries than AWS Athena or Azure Synapse for many workloads. Companies that primarily live on AWS still use BigQuery for their analytics warehouse. Similarly, Azure Entra ID is the best enterprise identity platform β a company on GCP might use Azure solely for SSO.
- Negotiating leverage: Cloud pricing is not fixed. Enterprise agreements with reserved instance commitments can be negotiated, especially for eight-figure annual spend. A company that has all its eggs in one cloud basket has no leverage. A company that can credibly say "we're evaluating moving our analytics workloads to BigQuery" has negotiating power with AWS. Even a small migration threat can result in meaningful pricing concessions.
- Resilience and disaster recovery: AWS us-east-1 has had notable outages that took down significant portions of the internet. For truly mission-critical systems β financial platforms, healthcare infrastructure, emergency services β a multi-cloud strategy ensures that a single cloud provider's failure cannot take the entire system offline.
- Regulatory and data residency requirements: Some countries require certain data to remain within their borders. If Cloud Provider A has a data center in a required jurisdiction and Cloud Provider B does not, a company might use both.
- Team preferences and skills: Different engineering teams within a large company may have different expertise. A team that has used Azure for years will be more productive there than being forced onto GCP. Large companies often give teams autonomy to use the cloud that best serves their needs.
Multi-cloud is not free. You pay in operational complexity β your team needs to know multiple CLIs, multiple IAM models, multiple networking concepts. Data transfer between cloud providers (egress) costs money. Tooling like Terraform and Kubernetes help abstract provider differences, but they are not magic. For most startups and small companies, committing to one cloud and learning it deeply is a far better strategy than spreading across three.
Part 3 Exercise Summary
These exercises covered the core concepts from all three chapters in Part 3:
- Exercise 1: Cloud Run maps to AWS App Runner most closely; Fargate and Lambda also partially overlap.
- Exercise 2: S3 is the right service for user-uploaded file storage β scalable, durable, and integrates with CloudFront.
- Exercise 3: IAM controls all access in AWS. Users are for humans, roles are for machines, policies define what's allowed.
- Exercise 4: Serverless means no server management; AWS Lambda / GCP Cloud Functions / Azure Functions. Advantages include zero idle cost and auto-scaling; disadvantages include cold starts and vendor lock-in.
- Exercise 5: Start Next.js on Vercel β zero config, free tier, optimal for the framework. Migrate when you hit genuine scale or infrastructure requirements.
- Exercise 6: EC2 is for persistent processes (WebSocket servers, long-running services); Lambda is for event-driven, short-lived functions.
- Exercise 7: Azure wins for Microsoft stacks β Entra ID, Azure SQL, and Azure DevOps all leverage existing Microsoft investments.
- Exercise 8: Custom VPCs give network segmentation and security. Databases go in private subnets β no public IP, not reachable from the internet.
- Exercise 9: Vercel is for modern JavaScript apps (auto-deploys from Git, global CDN); cPanel is for PHP/WordPress on traditional shared hosting.
- Exercise 10: Multi-cloud happens due to M&A, best-of-breed services, negotiating leverage, resilience requirements, and team preferences β with real complexity costs.