Skip to content
Visual explainer 6h to learn 5 steps

AWS capstone: operate, recover and clean up the platform

Show correlated logs, an idempotent worker, a failed delivery and replay, a rollback or restore, and a verified cleanup.

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

Topic 38 of 38

In short

The last milestone proves the service can be run, not just deployed. You follow one file through every log, show that a duplicate message changes nothing, break a delivery on purpose and replay it, roll back a release or restore data within your stated RTO, and finally delete everything and check the bill. Each step produces evidence, such as a query result, a screenshot or a command output, that goes into your capstone report.

Explained simply

A service that deploys is only half done. It also has to be run by tired people at odd hours. This milestone checks that you can see what happened to any single file, that the system copes with duplicates and failures, that you can undo a bad release or bad data, and that you can switch it all off.

You will break things on purpose. That sounds strange, but it is the only way to know your alarms, logs and recovery steps really work. A recovery plan that has never been tried is a guess. One that you have timed with a stopwatch is evidence.

Every task ends with proof you can show someone: a query result, an alarm history, a command output, a screenshot of the bill. Together these make your capstone report. Someone reading it should be able to trust that the service works without having to rebuild it.

The last step is cleanup, and it matters as much as the rest. Leftover snapshots, log groups and idle resources are how small labs turn into surprise bills. You finish by searching for anything still tagged with the project and checking the next day's costs.

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

CycleFail, observe, fix, replay
  1. 1
    Inject failure

    Deploy a worker version that rejects one file type

  2. 2
    Observe

    Errors metric rises, message lands in files-dlq, alarm fires

  3. 3
    Diagnose

    Logs Insights query by file_id shows the error

  4. 4
    Fix or roll back

    Point the live alias back to the good version

  5. 5
    Replay

    Move DLQ messages back to files-work and confirm results

  6. Back to step 1
MapCapstone evidence pack
Capstone report
  • Design
    • Runtime and network diagram
    • Role and permission matrix
    • Cost breakdown with fixed costs
  • Delivery
    • CI run log with OIDC session
    • Build and teardown commands
    • Sample event results
  • Reliability
    • Duplicate skipped log lines
    • DLQ alarm history and replay
    • Timed rollback or restore
  • Operations
    • Saved Logs Insights query
    • SLO dashboard over the test period
  • Cleanup
    • Empty tag search
    • Next-day cost graph

In depth

Correlating logs for one file

Have the API, the worker and any other step write one JSON line per event with the same fields: fileId, step, outcome and durationMs, plus the Lambda request ID that CloudWatch adds. The fileId is created when the upload URL is issued, or derived from the object, and travels in the S3 key or metadata.

Then one CloudWatch Logs Insights query across both log groups, filtered by fileId, shows the whole story in time order: URL issued, object received, processing started, result written. You can also turn on Lambda active tracing to see timings per call in X-Ray, but logs with a shared ID are enough for this milestone. Save the query in Logs Insights so you can reuse it during an incident.

  • Same fileId in every log line
  • Structured JSON so fields can be filtered
  • Query both log groups together
  • Save the query for incident use

Proving duplicates are ignored

SQS standard queues deliver at least once, and S3 notifications can occasionally repeat, so duplicates will happen. The worker handles them with a conditional write: the result is stored only if no item with that file_id exists. A failed condition means the work was already done, so the worker logs duplicate_skipped and lets the message be deleted.

To show it, send the same S3 event body to the queue twice with aws sqs send-message, or re-upload the same version. Evidence: one item in DynamoDB, two log lines for the fileId with outcomes processed and duplicate_skipped, and an unchanged processedAt timestamp. If the worker had side effects such as sending email, they also need the guard, for example by recording the side effect in the same conditional write.

Failing a delivery and replaying it

Deploy a worker version that throws for files whose name contains broken, and upload one. Watch it happen: the Lambda Errors metric rises, the message returns after each visibility timeout, and after five receives SQS moves it to files-dlq. Your alarm on the DLQ's ApproximateNumberOfMessagesVisible goes to ALARM and notifies you through SNS.

Diagnose with the saved Logs Insights query. Fix the code or roll back. Only then replay: aws sqs start-message-move-task with the DLQ ARN as source moves the messages back to the queue they came from, at a rate you can limit. Evidence: the alarm history, the error log line, the move task status, and the result item appearing after replay. Remember the DLQ's own retention period; messages older than it are deleted for good.

SequenceA failed message and its replay
files-work
Worker
files-dlq
Operator
  1. 1Deliver message, receive count 1
    files-work to Worker: Deliver message, receive count 1
  2. 2Reports failure; message reappears after timeout
    Worker to files-work: Reports failure; message reappears after timeout
  3. 3After 5 receives, moved to DLQ
    files-work to files-dlq: After 5 receives, moved to DLQ
  4. 4Alarm: DLQ depth above 0
    files-dlq to Operator: Alarm: DLQ depth above 0
  5. 5Fix released, start-message-move-task
    Operator to files-dlq: Fix released, start-message-move-task
  6. 6Message returned to source queue and processed
    files-dlq to files-work: Message returned to source queue and processed

Rolling back a release or restoring data

Show at least one of these, timed against your RTO. Release rollback: the event source mapping points at the live alias. Publish a bad version, move live to it, watch errors rise, then run aws lambda update-alias to point live back at the previous version. New invocations use the old code straight away. If you used CodeDeploy or weighted aliases in the release module, an alarm can roll back automatically.

Data restore: with PITR on, a bad batch job that overwrote results can be undone. Restore the table to a time just before the mistake as a new table, compare, then copy the correct items back or point the app at the restored table through configuration. For files, restore an overwritten object by copying a previous version back over it. Write down the start and end time of each drill; that is your measured RTO.

  • Rollback: update-alias to the last good version
  • PITR restores to a new table, never in place
  • S3: copy a previous version back to the key
  • Record start and end times as RTO evidence

Tearing down and checking the bill

Run your teardown script: empty the versioned bucket, delete the stack, wait for completion. Then look for what the stack did not own: log groups that Lambda created before the stack declared them, the CI artifact bucket, DynamoDB restore tables from drills, on-demand backups, and any resources you made by hand. Search by tag with the Resource Groups Tagging API, and check log groups by name prefix.

Cost data lags by up to a day. The next day, open Cost Explorer, filter by the project cost allocation tag (activated in the Billing console) and by service, and confirm charges stop. Keep the budget alert until the month ends. Evidence: the empty tag search, the empty log group listing and a screenshot of the daily cost graph flattening.

Learn it in 5 short steps

About 1h 10m each. Track them with a timer in your plan.

  1. 1
    Correlate logs for one file~1h 10m
  2. 2
    Prove duplicates are ignored~1h 10m
  3. 3
    Fail a delivery and replay it~1h 10m
  4. 4
    Roll back a release or restore data~1h 10m
  5. 5
    Tear down and check the bill~1h 10m

Key points

  • Log one JSON line per step with the same file_id, so a single CloudWatch Logs Insights query shows a file's whole journey.
  • Idempotency comes from a conditional write such as attribute_not_exists(file_id), so a second delivery is detected and skipped.
  • A dead-letter queue only helps if you alarm on its depth and know the replay command before you need it.
  • Rollback is fastest when the trigger points at a Lambda alias; moving the alias back is one command and takes effect at once.
  • Cleanup is not done until a tag search finds nothing and the next day's billing shows no new charges for the project.

Key terms

Tap a card to flip it. 0/5 known

Examples

bash
# replay everything in the DLQ back to its source queue
aws sqs start-message-move-task \
  --source-arn arn:aws:sqs:eu-west-1:<account-id>:files-dlq
# roll the worker back to version 7
aws lambda update-alias --function-name files-worker \
  --name live --function-version 7
# restore results to a new table from just before a bad write
aws dynamodb restore-table-to-point-in-time \
  --source-table-name files-results --target-table-name files-results-restore \
  --restore-date-time 2026-12-01T10:15:00Z

Three recovery commands to rehearse before an incident. Placeholders stand in for your account and times.

Following one file through the logs

A user says their file never got a result. Step 1: get the fileId from the API response the client stored. Step 2: open CloudWatch Logs Insights, select the API and worker log groups, and run the saved query with that ID. Step 3: read the outcome column: URL issued, then processing started three times with error, then nothing. Step 4: check files-dlq; the message is there. Step 5: the error line shows a missing column, so the fix is in parsing, followed by a replay.

text
fields @timestamp, @log, step, outcome, durationMs, error
| filter fileId = "f-2026-12-01-0042"
| sort @timestamp asc
| limit 50

A timed rollback drill

Step 1: note the current live version, say 7. Step 2: publish version 8 with a deliberate bug and move live to it; record the time. Step 3: upload a sample; the Errors alarm fires within a few minutes. Step 4: roll back and record the time. Step 5: replay the DLQ and confirm results. In this run the alarm took 4 minutes and the rollback 1 minute, well inside a 1-hour RTO. Write those numbers in the report.

bash
aws lambda get-alias --function-name files-worker --name live \
  --query FunctionVersion            # "7"
aws lambda update-alias --function-name files-worker \
  --name live --function-version 8   # bad release, 10:02
# ... alarm fires 10:06 ...
aws lambda update-alias --function-name files-worker \
  --name live --function-version 7   # rolled back, 10:07
aws sqs start-message-move-task \
  --source-arn arn:aws:sqs:eu-west-1:<account-id>:files-dlq

Quick reference

  • Log one JSON line per step with fileId, step, outcome, durationMs
  • Idempotency: ConditionExpression attribute_not_exists(file_id)
  • Alarm on files-dlq ApproximateNumberOfMessagesVisible above 0
  • Replay: aws sqs start-message-move-task --source-arn DLQ_ARN (fix the bug first)
  • Rollback: aws lambda update-alias --name live --function-version LAST_GOOD
  • PITR restore always creates a new table: compare, then copy back or switch config
  • Cleanup proof: empty tag search, no project log groups, flat next-day cost

Common mistakes

  • Replaying the DLQ before fixing the bug, so every message fails again and returns to the DLQ.
  • Counting a restore as done when the new table exists; the app still points at the old table until you switch or copy back.
  • Deleting the stack and assuming the bill stops, while log groups, snapshots or an artifact bucket created outside the stack remain.

Quick quiz

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

Question 1

1Ten messages sit in files-dlq because of a parsing bug. What is the right order?

Question 2

2What is the strongest evidence that the worker is idempotent?

Question 3

3You restore the results table with PITR. Users still see the bad data. Why?

Question 4

4The stack is deleted but costs continue the next day. What is the most likely cause?

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

    Send the same message to files-work twice and collect the evidence that only one result was stored.

  2. Exercise 2medium

    Create a CloudWatch alarm that fires when any message is visible in files-dlq and notifies an SNS topic.

  3. Exercise 3hard

    Run a data-restore drill: corrupt three result items, restore the table to a time before the change, copy the three correct items back, and record your RTO.

Check yourself

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

Feel confident about this topic?

Frequently asked questions

How long should the capstone take?
Plan about 18 hours: 4 for the design, 8 for delivery and 6 for operations. Drills that wait on retries and alarms take wall-clock time, so start them early and write up while you wait.
Which AWS certification fits after this path?
Certification is optional. As of December 2026, AWS lists associate exams such as Solutions Architect, Developer and CloudOps Engineer, the DevOps Engineer professional exam, and Security specialty; Advanced Networking specialty retires on 31 December 2026. Several exams are being updated, so check aws.amazon.com/certification for current versions before you book.
What if I cannot use a real AWS account?
Run the worker locally against moto or DynamoDB local, simulate duplicates and failures with saved events, and write the alarm, replay and restore steps as a runbook with the exact commands. Mark that evidence as simulated in your report.
Do I need X-Ray tracing to pass?
No. Structured logs with a shared fileId meet the correlation goal. Tracing is a useful extra when you want per-call timings across services.

Go deeper

ShareXLinkedInWhatsApp