Skip to content
Visual explainer 4h to learn 5 steps

AWS capstone: design the file-processing architecture

Produce runtime and network diagrams, a role and permission matrix, a data lifecycle, a cost estimate and recovery goals.

By Invicly Tech, , in AWS Cloud Engineering. About 14 minutes to read.

Topic 36 of 38

In short

The capstone starts on paper: before you deploy anything, you write down how a file moves through the service, who may touch what, how long data lives, what it costs and how fast you must recover. These design documents become the checklist you test against in the delivery and operations milestones. A reviewer should be able to read them and predict the bill, the blast radius of a leaked credential and the recovery time.

Think of it like this: It is the architect's drawing set for a house: floor plan, wiring diagram, key list and budget, all agreed before the first wall goes up.

Explained simply

The capstone pulls the whole path together into one working service. People upload files, a worker processes each file, and the results are saved so the app can show them. You have built most pieces in earlier modules. Now you design them as one system, deploy it the way a team would, run it, break it, fix it and finally delete it.

Design comes first because changes on paper are free. Moving a function out of a VPC after launch means a migration. Moving it on a diagram means an eraser. The design also tells you what to test later. If you write that files must be processed within five minutes, you will have to measure that.

You produce five things in this milestone: a runtime and network diagram, a role and permission matrix, a data lifecycle table, a cost estimate and a short statement of recovery goals. Each fits on one page. Together they let a reviewer understand the service without opening the code.

Keep the lab small and cheap. Use tiny synthetic text and CSV files, such as invoices for Contoso and Fabrikam, never real customer data. Everything in the core design stays on serverless services that cost little when idle. Anything expensive, such as a container cluster or a NAT gateway, appears only as a written design unless you choose to pay for it.

Press Play on a diagram to walk through it one step at a time.

FlowIngestion and processing flow for one file
  1. 1
    Request upload URL

    Client calls the API; a Lambda returns a presigned S3 PUT URL

  2. 2
    Upload

    File lands in the uploads bucket under incoming/

  3. 3
    Event

    S3 sends an object-created notification to the files-work queue

  4. 4
    Process

    Worker Lambda reads the file, extracts results

  5. 5
    Store

    Conditional write of the result to DynamoDB, keyed by file_id

  6. 6
    Fail safely

    After 5 failed receives the message moves to files-dlq

LayersRuntime and network view
  1. 1
    Clients

    Call the HTTP API over HTTPS; upload straight to S3

  2. 2
    Edge of AWS

    API Gateway HTTP API and the S3 regional endpoint

  3. 3
    Compute

    API Lambda and worker Lambda, no VPC needed for this design

  4. 4
    Messaging

    SQS files-work queue and files-dlq dead-letter queue

  5. 5
    Data

    S3 uploads bucket (versioned, encrypted) and DynamoDB results table

  6. 6
    Operations

    CloudWatch Logs, metrics and alarms, CloudTrail, AWS Budgets

CompareFixed costs to keep or design away
Keep in the lab
  • S3 storage with lifecycle rules
  • DynamoDB on demand
  • Lambda and SQS per request
  • Log groups with 14-day retention
Design only by default
  • NAT gateway
  • Application Load Balancer
  • ECS Fargate service running all day
  • Customer managed KMS keys
Watch after teardown
  • Snapshots and backup points
  • Noncurrent S3 versions
  • Log groups created outside the stack
  • Public IPv4 addresses

In depth

Drawing the runtime and network diagram

Draw boxes for every component and arrows for every call, and label each arrow with the protocol and the identity used. The client calls an API Gateway HTTP API, which invokes an API Lambda. That Lambda returns a presigned PUT URL. The client uploads to the uploads bucket. S3 sends an object-created notification for the incoming/ prefix to the files-work SQS queue, which needs a queue policy allowing the S3 service to send messages from that bucket. A Lambda event source mapping polls the queue and invokes the worker, which reads the object and writes to the DynamoDB results table. After a set number of failed receives, SQS moves a message to files-dlq.

Note what is not there. The Lambdas run outside any VPC, so there are no subnets, NAT gateway or endpoints to pay for. If a later version needs a private database, add a VPC with gateway endpoints for S3 and DynamoDB and draw that change explicitly.

  • Every arrow: protocol plus calling role
  • Mark trust boundaries: internet, AWS public endpoints, your account
  • Show the failure path to the DLQ, not just the happy path

The role and permission matrix

List every principal as a row: the API Lambda role, the worker role, the CI deploy role, the human operator role and the S3 service writing to SQS. For each, list actions and exact resource ARNs. The API role needs s3:PutObject on incoming/* (to sign upload URLs) and dynamodb:GetItem on the results table. The worker needs s3:GetObject on incoming/*, the SQS receive, delete and get-attributes actions on files-work, and dynamodb:PutItem on the results table. The deploy role needs CloudFormation plus the create and update actions for the stack's resources, ideally limited by a permissions boundary.

Then add a column for how you will test each row: a call that should succeed and one that should be denied. A denied call in CloudTrail or an AccessDenied error is your evidence that least privilege holds.

MapPrincipals and their permissions
files-lab account
  • API Lambda role
    • s3:PutObject on incoming/*
    • dynamodb:GetItem on files-results
  • Worker role
    • s3:GetObject on incoming/*
    • sqs:ReceiveMessage, DeleteMessage, GetQueueAttributes
    • dynamodb:PutItem on files-results
  • S3 service principal
    • sqs:SendMessage on files-work
    • Condition: aws:SourceArn is the uploads bucket
  • CI deploy role
    • Trusted only from repo main via OIDC
    • CloudFormation and stack resource actions
  • Operator role
    • Read logs and metrics
    • Redrive DLQ, update alias, restore table

Data lifecycle and retention

Write one row per kind of data: raw uploads, results, logs, invocation logs if you use Bedrock, and backups. For each, state where it lives, who reads it, how long you keep it and how it is deleted. A sensible lab default: uploads under incoming/ expire after 7 days through an S3 lifecycle rule; noncurrent object versions expire after 3 days; incomplete multipart uploads are aborted after 1 day; results in DynamoDB carry an expires_at attribute used by TTL after 90 days; Lambda log groups keep 14 days.

Versioning on the uploads bucket protects against accidental overwrites and deletes, which supports your RPO. DynamoDB point-in-time recovery, with a recovery period you choose up to 35 days, protects the results table. Encrypt everything at rest; SSE-S3 and the DynamoDB default AWS owned key cost nothing extra.

  • S3 lifecycle per prefix
  • Noncurrent versions expire, or versioning quietly doubles storage
  • DynamoDB TTL for results, PITR for mistakes
  • Set log retention on every log group

Estimating cost, including the quiet items

Start from a usage profile, for example 10,000 files a month, 200 KB each, 2 seconds of worker time at 512 MB. Multiply by prices from the AWS pricing pages or the AWS Pricing Calculator: Lambda requests and GB-seconds, SQS requests, S3 storage and requests, DynamoDB on-demand writes and reads, API Gateway requests. At this size the variable cost is small.

The surprises are the fixed or slowly growing costs. A NAT gateway bills per hour and per GB processed even when idle. An Application Load Balancer bills per hour. Public IPv4 addresses bill per hour. CloudWatch Logs storage grows forever unless you set retention. EBS and RDS snapshots, AWS Backup recovery points and old S3 versions keep billing after the lab is forgotten. Customer managed KMS keys have a monthly fee. List each one, either with a number or with design-only as the decision.

Stating SLO, RPO and RTO

Pick targets you can measure with CloudWatch. SLO: 99 percent of uploaded files have a result within 5 minutes, measured over 28 days. Measure it with the SQS ApproximateAgeOfOldestMessage metric and a custom metric for end-to-end processing time that the worker publishes. RPO: no more than 5 minutes of results lost, met by DynamoDB PITR and S3 versioning. RTO: service restored within 1 hour after a bad release or data corruption, met by an alias rollback or a table restore you have rehearsed.

Write down how each will be proved in the operations milestone. A goal with no test is only a wish.

  • SLO: 99 percent of files within 5 minutes
  • RPO: 5 minutes
  • RTO: 1 hour
  • Each with a named metric or drill as evidence

Learn it in 5 short steps

About 50m each. Track them with a timer in your plan.

  1. 1
    Draw the ingestion and processing flow~50m
  2. 2
    Write the role and permission matrix~50m
  3. 3
    Define data lifecycle and retention~50m
  4. 4
    Estimate costs including NAT and logs~50m
  5. 5
    Set the SLO, RPO and RTO~50m

Key points

  • Keep the Lambdas out of a VPC unless they must reach private resources; that avoids a NAT gateway, often the largest fixed cost in small labs.
  • Write one role per component and list every action and resource in a matrix; the matrix is what you review and test.
  • Define lifecycle rules per prefix: raw uploads expire, results keep longer, noncurrent versions expire after a few days.
  • Estimate cost from usage numbers, then add the quiet costs: NAT, log storage, load balancers, public IPv4 addresses, snapshots and backups.
  • State an SLO, an RPO and an RTO in numbers, because the operations milestone must prove you meet them.

Key terms

Tap a card to flip it. 0/5 known

Examples

A one-page cost estimate for the lab month

Step 1: write the usage profile: 10,000 files, 200 KB each, 2 s at 512 MB per file, 20,000 API calls. Step 2: compute units: about 2 GB uploaded, 10,000 GB-seconds of worker time, roughly 30,000 SQS requests including receives and deletes, 10,000 DynamoDB writes. Step 3: multiply by current Region prices from the pricing pages, labelled with the date you checked. Step 4: add fixed items as a separate list, each marked included or design-only. Step 5: set an AWS Budgets alert at twice the estimate.

text
Variable (monthly, lab)        units              price source
Lambda worker compute          10,000 GB-s        Lambda pricing
Lambda + API requests          30,000 requests    Lambda / API Gateway
SQS requests                   ~30,000            SQS pricing
S3 storage (7-day expiry)      ~0.5 GB average    S3 pricing
DynamoDB on-demand writes      10,000             DynamoDB pricing
Fixed or growing
NAT gateway                    design-only        VPC pricing
CloudWatch Logs                14-day retention   CloudWatch pricing
Budget alert                   2 x estimate       AWS Budgets

Writing the matrix row for the worker and testing it

Step 1: list what the worker does: read the uploaded object, take and delete queue messages, write one result. Step 2: map each to an action and exact ARN. Step 3: write the policy. Step 4: test a permitted call (process a sample file) and a forbidden one (from a test event, try to delete the object). Expected evidence: the result item exists, and the delete attempt logs AccessDenied. Record both in the matrix.

yaml
- Effect: Allow
  Action: s3:GetObject
  Resource: !Sub "${UploadsBucket.Arn}/incoming/*"
- Effect: Allow
  Action: [sqs:ReceiveMessage, sqs:DeleteMessage, sqs:GetQueueAttributes]
  Resource: !GetAtt WorkQueue.Arn
- Effect: Allow
  Action: dynamodb:PutItem
  Resource: !GetAtt ResultsTable.Arn

Quick reference

  • Deliverables: diagram, role matrix, lifecycle table, cost estimate, SLO/RPO/RTO
  • Lambdas outside a VPC need no NAT gateway to reach S3, SQS or DynamoDB
  • S3 to SQS notifications need a queue policy for s3.amazonaws.com with aws:SourceArn
  • Expire noncurrent versions and abort incomplete multipart uploads in lifecycle rules
  • CloudWatch Logs groups never expire by default: set retention on each one
  • Quiet costs: NAT, load balancers, public IPv4, logs, snapshots, backups, KMS keys
  • Every target needs evidence: a metric, a query or a timed drill

Common mistakes

  • Putting the worker in a private subnet by habit, then paying for a NAT gateway around the clock just to reach S3, SQS and DynamoDB.
  • Writing a cost estimate that covers requests and compute but forgets CloudWatch Logs storage, which never expires by default.
  • Setting an RPO of zero without a design that can deliver it, such as versioning plus point-in-time recovery.

Quick quiz

Pick an answer to see if you're right and why.

Question 1

1The worker only talks to S3, SQS and DynamoDB. A teammate wants it in a private subnet with a NAT gateway. What is the strongest objection for this lab?

Question 2

2Which lifecycle rule stops versioning from quietly doubling storage?

Question 3

3Which metric best supports an SLO that files are processed within 5 minutes?

Question 4

4Which item should a role and permission matrix contain for each principal?

0/4 answered

Practice exercises

Try each one yourself first. Use the hint if you get stuck, then compare with the solution.

  1. Exercise 1easy

    Write the data lifecycle table for the four data types in the service: raw uploads, results, worker logs and old object versions.

  2. Exercise 2medium

    Draft the role and permission matrix for the API Lambda, including one allowed and one denied test call.

  3. Exercise 3hard

    A reviewer asks you to add a private PostgreSQL database for reports. Update the design and list every new cost and permission.

Check yourself

Answer in your head, reveal, then be honest with yourself.

Feel confident about this topic?

Frequently asked questions

Do I have to pay to complete the capstone?
The core serverless design costs very little at lab scale, but it is not guaranteed to be free, because Free Tier rules change. Set a budget alert, keep files tiny, and treat NAT gateways, load balancers and container services as design-only unless you choose to pay.
Which diagram tool should I use?
Any tool that exports an image or text works. A text format such as Mermaid or a draw.io file kept in the repository is easiest to review and version alongside the code.
Why not run the worker on ECS from the start?
Lambda with SQS is simpler and cheaper for short jobs. The container option is designed in the next milestone for files that need more than Lambda's 15-minute limit or special libraries.

Go deeper

ShareXLinkedInWhatsApp