Project Workshop — Serverless Thumbnail Generator
This is a portfolio submission, not a copy-and-run tutorial. A reviewer must be able to clone it, configure it without guessing, execute the critical path, observe a deliberate failure, run the tests, and understand the most important…
- What you are building
- Architecture
- Acceptance criteria
- Suggested repository structure
- Build plan: vertical slices
AWS Lambda · S3 · SNS · SQS · DynamoDB · API Gateway · boto3
Expected effort: 10–16 focused hours · Minimum meaningful tests: 12What you are building
This is a portfolio submission, not a copy-and-run tutorial. A reviewer must be able to clone it, configure it without guessing, execute the critical path, observe a deliberate failure, run the tests, and understand the most important design decision from the README.
Architecture
Critical interaction
Ownership table
| Boundary | Owns | Must not own |
|---|---|---|
| Interface | Parsing, protocol validation, identity extraction, status or presentation mapping | Core business invariants |
| Application/domain | Authorization inputs, state transitions, orchestration, transaction intent | Framework globals or raw transport objects |
| Repository/gateway | One persistence or external protocol, bounded retries, error translation | Product policy |
| Background/UI projection | Recoverable derived state and delivery progress | Hidden authoritative truth |
| Operations | Configuration, health, deployment, telemetry, recovery | Business decisions encoded only in dashboards |
Acceptance criteria
| ID | Required behavior | Evidence |
|---|---|---|
| AC-1.1 | EC2: instance types/AMIs/user data/instance profiles produces the specified behavior inside Core services | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-1.2 | VPC: subnets (public/private)/route tables/IGW/NAT produces the specified behavior inside Core services | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-1.3 | S3: bucket policies/presigned URLs/lifecycle/versioning produces the specified behavior inside Core services | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-1.4 | RDS: Multi-AZ/read replicas/parameter groups produces the specified behavior inside Core services | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-1.5 | IAM: users/groups/roles/policies/STS assume role produces the specified behavior inside Core services | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-2.1 | Lambda: handler/event/context, layers, cold start optimization produces the specified behavior inside Serverless | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-2.2 | triggers: API GW/S3/SQS/EventBridge/Cognito produces the specified behavior inside Serverless | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-2.3 | concurrency: reserved and provisioned produces the specified behavior inside Serverless | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-2.4 | API Gateway: REST vs HTTP API vs WebSocket API produces the specified behavior inside Serverless | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.1 | SQS standard vs FIFO, visibility timeout, DLQ produces the specified behavior inside SQS, SNS & data services | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.2 | SNS fan-out: SNS → multiple SQS queues produces the specified behavior inside SQS, SNS & data services | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.3 | MSK (Managed Kafka) + ElastiCache (Redis Cluster) produces the specified behavior inside SQS, SNS & data services | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.4 | DynamoDB: partition key design/GSI/LSI/Streams produces the specified behavior inside SQS, SNS & data services | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-4.1 | User Pools: JWT tokens + triggers produces the specified behavior inside Cognito & Step Functions | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-4.2 | Cognito + API Gateway authorizer produces the specified behavior inside Cognito & Step Functions | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-4.3 | WAF: rate limiting + OWASP rules produces the specified behavior inside Cognito & Step Functions | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-4.4 | Step Functions: states/error handling/Express vs Standard produces the specified behavior inside Cognito & Step Functions | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-5.1 | security groups vs network ACLs produces the specified behavior inside Additional backend services | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-5.2 | Lambda with RDS Proxy connection management produces the specified behavior inside Additional backend services | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-5.3 | Athena query over partitioned S3 data produces the specified behavior inside Additional backend services | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-5.4 | EventBridge bus/rule/archive/replay produces the specified behavior inside Additional backend services | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-5.5 | Route 53 routing policies and health checks produces the specified behavior inside Additional backend services | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-5.6 | CloudFront origin access control and cache policy produces the specified behavior inside Additional backend services | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-5.7 | Bedrock model invocation basics produces the specified behavior inside Additional backend services | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-5.8 | SageMaker training vs managed inference basics produces the specified behavior inside Additional backend services | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
Suggested repository structure
1delivery/2├── app/3├── Dockerfile4├── compose.yaml5├── .github/workflows/6├── deploy/{base,overlays,helm}/7├── cloud/{sam,terraform}/8├── observability/{prometheus,grafana,otel,alerts}/9├── tests/{smoke,policy,load}/10└── runbooks/Build plan: vertical slices
| Milestone | Capability | First implementation | Exit condition |
|---|---|---|---|
| 1 | Core services | EC2: instance types/AMIs/user data/instance profiles; VPC: subnets (public/private)/route tables/IGW/NAT; S3: bucket policies/presigned URLs/lifecycle/versioning | Demonstration plus focused tests |
| 2 | Serverless | Lambda: handler/event/context, layers, cold start optimization; triggers: API GW/S3/SQS/EventBridge/Cognito; concurrency: reserved and provisioned | Demonstration plus focused tests |
| 3 | SQS, SNS & data services | SQS standard vs FIFO, visibility timeout, DLQ; SNS fan-out: SNS → multiple SQS queues; MSK (Managed Kafka) + ElastiCache (Redis Cluster) | Demonstration plus focused tests |
| 4 | Cognito & Step Functions | User Pools: JWT tokens + triggers; Cognito + API Gateway authorizer; WAF: rate limiting + OWASP rules | Demonstration plus focused tests |
| 5 | Additional backend services | security groups vs network ACLs; Lambda with RDS Proxy connection management; Athena query over partitioned S3 data | Demonstration plus focused tests |
| 6 | Hardening and delivery | Security, recovery, telemetry, performance, documentation | Full acceptance suite and recorded demonstration |
For each milestone, first create a failing acceptance test or a reproducible command. Implement the thinnest path to an observable result, add the nearest durable invariant, inject one expected failure, and refactor only after evidence protects the behavior.
Reference vertical slice
1import boto32
3s3 = boto3.client("s3")4sqs = boto3.client("sqs")5
6def handler(event, context):7 failures = []8 for record in event.get("Records", []):9 try:10 event_id = record["messageId"]11 payload = parse(record["body"])12 if claim_idempotency_key(event_id):13 transform_s3_object(s3, payload["bucket"], payload["key"])14 except Exception:15 failures.append({"itemIdentifier": record["messageId"]})16 return {"batchItemFailures": failures}Expected result
1An SQS-triggered Lambda retries only failed records and deduplicates successful side effects.Code reading
| Line | Code | Explanation |
|---|---|---|
| 1 | import boto3 | Imports the named dependency; import executes the module once per interpreter cache and binds selected names here. |
| 3 | s3 = boto3.client("s3") | Computes or receives a value and binds it for the next step; the referenced object remains separate from the name. |
| 4 | sqs = boto3.client("sqs") | Computes or receives a value and binds it for the next step; the referenced object remains separate from the name. |
| 6 | def handler(event, context): | Defines a function; its parameters form the explicit input boundary. |
| 7 | failures = [] | Computes or receives a value and binds it for the next step; the referenced object remains separate from the name. |
| 8 | for record in event.get("Records", []): | Consumes the iterable one item at a time through the iterator protocol. |
| 9 | try: | Defines failure translation or cleanup that must run around the protected operation. |
| 10 | event_id = record["messageId"] | Computes or receives a value and binds it for the next step; the referenced object remains separate from the name. |
| 11 | payload = parse(record["body"]) | Computes or receives a value and binds it for the next step; the referenced object remains separate from the name. |
| 12 | if claim_idempotency_key(event_id): | Evaluates the condition and enters this branch only when it is truthy. |
| 13 | transform_s3_object(s3, payload["bucket"], payload["key"]) | Implements the next python statement in the example's data flow. |
| 14 | except Exception: | Defines failure translation or cleanup that must run around the protected operation. |
| 15 | failures.append({"itemIdentifier": record["messageId"]}) | Implements the next python statement in the example's data flow. |
| 16 | return {"batchItemFailures": failures} | Returns the observable result to the caller and ends this invocation. |
Risk register
| Area | Failure to reproduce | Required design response |
|---|---|---|
| Core services | A public subnet is defined by routing, not by its name; a read replica is not the same as a synchronous standby. | Use roles and short-lived STS credentials, private subnets for data, endpoint policies, encryption, and Multi-AZ for availability. |
| Serverless | A longer visibility timeout and retry policy are required for batch work; global state is reusable but not durable. | Initialize clients outside the handler, make handlers idempotent, and configure partial batch failure where supported. |
| SQS, SNS & data services | FIFO ordering is per message group and does not remove duplicate-delivery handling. | Use DLQs, idempotent consumers, per-tenant hot-key analysis, and explicit ordering scope. |
| Cognito & Step Functions | Authentication does not provide application object authorization. | Validate issuer/audience, use least-privilege task roles, and define catches/timeouts at each state. |
| Additional backend services | Leaving endpoints idle creates cost, while promoting an artifact without data lineage and evaluation makes rollback and incident diagnosis unreliable. | Separate data/code/model versions, encrypt inputs and artifacts, size from measured latency/throughput, monitor drift/errors, and retain rollback models. |
Engineering checklist for this stack
- To do: run with least privilege and immutable artifacts
- To do: declare resource bounds and health behavior
- To do: separate secrets from versioned configuration
- To do: prove rollback and restore
- To do: correlate deployment version with metrics, logs, and traces
Test strategy
Implement at least 12 meaningful cases. A long list of shallow happy-path tests does not satisfy the requirement.
| Risk class | Minimum | Examples |
|---|---|---|
| Happy path and contract | 2 | Correct output, status/schema, durable state |
| Validation and boundaries | 2 | Empty, malformed, extreme, unsupported transition |
| Authorization or trust boundary | 1 | Missing identity, wrong tenant/role, injection or unsafe content |
| Failure and recovery | 2 | Timeout, retry, rollback, reconnect, dependency outage |
| Duplicate or concurrency | 1 | Same identity twice, racing update, redelivery |
| Performance and operations | 4 | Query bound, lag, p95, resource limit, telemetry |
Representative test scaffold
1set -euo pipefail2docker build --check .3trivy image --exit-code 1 "$IMAGE_DIGEST"4helm lint ./deploy/helm5helm template test ./deploy/helm | kubeconform -strict6pytest -q tests/smoke7locust --headless --users 100 --spawn-rate 10 --run-time 2mFailure drills
- Stop the primary external dependency during the critical path. Capture the failure, cleanup, telemetry, and recovery.
- Repeat the same operation with the same stable identity. Prove one logical outcome or document why repetition is forbidden.
- Crash after durable state changes but before the response, acknowledgement, or projection. Re-run and reconcile.
- Submit the largest supported input and one slightly larger input.
- Remove one permission and prove denial without state change or information leakage.
- Roll back the change or restore the dependency, then run a smoke test and reconciliation check.
Performance experiment
State the dataset, payload distribution, concurrency, rate, duration, cache state, and resource limits before measuring. Publish p50, p95, p99, throughput, error rate, and the technology-specific correctness signal such as query count, consumer lag, duplicate effects, rendered updates, token cost, or recall. Change one variable at a time and retain raw output.
Submission package
- Complete source with a locked/reproducible environment.
- README.md with problem, architecture, setup, commands, configuration, assumptions, and trade-offs.
- Acceptance and risk-focused tests with a short explanation of what mocks intentionally do not cover.
- One design record explaining the most consequential choice and a rejected alternative.
- Security notes, sample non-secret configuration, and cleanup commands.
- A demonstration record: terminal transcript, screenshots, trace, query plan, or metrics dashboard.
- A 5–8 minute walkthrough following input → validation → state → failure → evidence.
Grading rubric
| Dimension | Weight | Full-credit evidence |
|---|---|---|
| Product behavior | 25 | Acceptance criteria pass through real public boundaries |
| Architecture and ownership | 20 | Responsibilities and state authority are explicit |
| Tests and recovery | 20 | Important negative, duplicate, concurrent, and outage cases pass |
| Security and data correctness | 15 | Least privilege, validation, constraints, and secret handling are demonstrated |
| Performance and operations | 10 | Reproducible measurement, useful telemetry, and rollback/recovery |
| Documentation and explanation | 10 | A new reviewer can reproduce and defend the result |
Mastery check
How well can you recall this?
Finished this lesson?