Ravindra BagaleCourses & study guides Track your progress

AWS Cloud

Amazon DynamoDB Hands-On Interview Questions: CLI Queries, Expressions, Errors and Operations (50 Questions)

This page has 50 hands-on DynamoDB interview questions with full answers. The basics (keys, capacity modes, indexes and consistency) are in Set 1, and the deep-dive page in this set covers data modelling. Here you practise the commands and errors you meet when you actually work with tables.

1. An everyday example: a library card index

Why do hands-on DynamoDB questions matter?

DynamoDB is simple until you write your first update expression or hit a ValidationException at 2 a.m. Interviewers for backend and cloud roles want to see that you can read and write data correctly, page through results, and understand the errors.

Think of a library card index. The partition key is the drawer, the sort key is the order of cards inside the drawer, and a query is "open this drawer and read cards from A to F". A scan is reading every card in every drawer, which is slow. Expressions are the instructions you write on the request slip.

How to use this page

  • Create a small test table called orders with pk (string) and sk (string), in on-demand mode.
  • Run each command and read the output aloud.
  • All names here are examples, such as account 111122223333.

2. Fresher level questions

Start here if you are a fresher or have less than two years of experience. Try to answer each question aloud first. Then open it and compare.

Q1. How do you create a small on-demand DynamoDB table with a partition key and sort key from the CLI? Fresher
aws dynamodb create-table --table-name orders --attribute-definitions AttributeName=pk,AttributeType=S AttributeName=sk,AttributeType=S --key-schema AttributeName=pk,KeyType=HASH AttributeName=sk,KeyType=RANGE --billing-mode PAY_PER_REQUEST

Output:

"TableStatus": "CREATING"
aws dynamodb wait table-exists --table-name orders

The table is being created. You only define key attributes; other attributes can be different in every item.

HASH is the partition key and RANGE is the sort key.

Q2. How do you write one item with the CLI, and what does the "S" and "N" mean? Fresher
aws dynamodb put-item --table-name orders --item '{"pk":{"S":"CUST#101"},"sk":{"S":"ORDER#2026-11-20#5001"},"total":{"N":"1499"},"status":{"S":"PAID"}}'

One order item is saved. "S" means string and "N" means number. Numbers are sent as strings in JSON but stored as numbers.

Other types include BOOL, NULL, L (list), M (map), SS (string set), NS (number set) and B (binary).

put-item replaces the whole item if the same key already exists, unless you add a condition.

Q3. How do you read one item by its full key? Fresher
aws dynamodb get-item --table-name orders --key '{"pk":{"S":"CUST#101"},"sk":{"S":"ORDER#2026-11-20#5001"}}'

Output:

{"Item": {"pk": {"S": "CUST#101"}, "sk": {"S": "ORDER#2026-11-20#5001"}, "total": {"N": "1499"}, "status": {"S": "PAID"}}}

The item was found. If the key does not exist, the response has no Item field (it is not an error).

For a table with a sort key, you must give both pk and sk for get-item.

Q4. How do you query all orders of one customer, newest first? Fresher
aws dynamodb query --table-name orders --key-condition-expression "pk = :p AND begins_with(sk, :o)" --expression-attribute-values '{":p":{"S":"CUST#101"},":o":{"S":"ORDER#"}}' --no-scan-index-forward --max-items 5

DynamoDB reads only the CUST#101 partition, items whose sort key starts with ORDER#, in descending order (newest first because the date is in the sort key).

--no-scan-index-forward reverses the sort order. The key condition can use =, <, >, BETWEEN and begins_with on the sort key.

Q5. Why does --key-condition-expression "status = :s" fail on the orders table? Fresher

A key condition can only use the table's (or index's) key attributes. status is a normal attribute.

Output:

An error occurred (ValidationException) when calling the Query operation: Query condition missed key schema element: pk

Query always needs the partition key.

Options:

  • Use a filter expression together with a proper key condition (still reads all items for that key).
  • Create a GSI with status as part of the key if you often need "orders by status".
Q6. What does a filter expression do, and why doesn't it reduce read cost? Fresher

A filter expression removes items from the result after DynamoDB has read them.

aws dynamodb query --table-name orders --key-condition-expression "pk = :p" --filter-expression "total > :t" --expression-attribute-values '{":p":{"S":"CUST#101"},":t":{"N":"1000"}}' --return-consumed-capacity TOTAL

Output:

"Count": 3, "ScannedCount": 40, "ConsumedCapacity": {"CapacityUnits": 5.0}

DynamoDB read 40 items (and charged for them) but returned only 3.

If ScannedCount is much bigger than Count, design a better key or index.

Q7. You get "Attribute name is a reserved keyword; reserved keyword: status". How do you fix it? Fresher

Many common words (status, name, date, year, size and hundreds more) are reserved in DynamoDB expressions. Use a placeholder:

aws dynamodb query --table-name orders --key-condition-expression "pk = :p" --filter-expression "#st = :s" --expression-attribute-names '{"#st":"status"}' --expression-attribute-values '{":p":{"S":"CUST#101"},":s":{"S":"PAID"}}'

#st stands for the attribute name status, and :s stands for the value.

Many teams use placeholders for every attribute name to avoid this problem.

Q8. How do you return only some attributes from a query? Fresher

Use a projection expression:

aws dynamodb get-item --table-name orders --key '{"pk":{"S":"CUST#101"},"sk":{"S":"ORDER#2026-11-20#5001"}}' --projection-expression "#t, #st" --expression-attribute-names '{"#t":"total","#st":"status"}'

Output:

{"Item": {"total": {"N": "1499"}, "status": {"S": "PAID"}}}

Only total and status came back.

This reduces network data, but not read capacity: DynamoDB still reads the full item to return a part of it.

Q9. How do you count items for one partition key without downloading them? Fresher

Use --select COUNT:

aws dynamodb query --table-name orders --key-condition-expression "pk = :p" --expression-attribute-values '{":p":{"S":"CUST#101"}}' --select COUNT

Output:

{"Count": 40, "ScannedCount": 40}

The customer has 40 items. Data is not returned, but DynamoDB still reads the items, so you pay for the reads.

For large tables, a full count with scan is expensive. Keep counters in a separate item if you need counts often.

Q10. How do you delete an item only if it has a certain status? Fresher
aws dynamodb delete-item --table-name orders --key '{"pk":{"S":"CUST#101"},"sk":{"S":"ORDER#2026-11-20#5001"}}' --condition-expression "#st = :s" --expression-attribute-names '{"#st":"status"}' --expression-attribute-values '{":s":{"S":"CANCELLED"}}'

Output:

An error occurred (ConditionalCheckFailedException) when calling the DeleteItem operation: The conditional request failed

The item was not cancelled, so DynamoDB did not delete it. This protects you from deleting the wrong data.

Q11. How do you see a table's key schema, item count and status? Fresher
aws dynamodb describe-table --table-name orders --query "Table.[TableStatus,ItemCount,TableSizeBytes,KeySchema,BillingModeSummary.BillingMode]"

Output:

["ACTIVE", 12045, 3456789, [{"AttributeName":"pk","KeyType":"HASH"},{"AttributeName":"sk","KeyType":"RANGE"}], "PAY_PER_REQUEST"]

The table is active, on-demand, with about 12,045 items.

ItemCount and TableSizeBytes are updated about every six hours, so they are not exact real-time numbers.

Q12. How do you turn on deletion protection for a DynamoDB table? Fresher
aws dynamodb update-table --table-name orders --deletion-protection-enabled

Check:

aws dynamodb describe-table --table-name orders --query "Table.DeletionProtectionEnabled"

Output:

true

delete-table now fails until someone turns the setting off, which needs a separate, deliberate action.

Turn it on for every production table, ideally in your IaC templates.

Q13. How do you scan a table page by page from the CLI? Fresher

The CLI pages automatically, but you can control page size and continue later:

aws dynamodb scan --table-name orders --max-items 100 --page-size 50

Output:

"NextToken": "eyJFeGNsdXNpdmVTdGFydEtleSI6..."
aws dynamodb scan --table-name orders --max-items 100 --page-size 50 --starting-token eyJFeGNsdXNpdmVTdGFydEtleSI6...

The first call returned 100 items and a token; the second continues from there. In SDK code, you use LastEvaluatedKey and ExclusiveStartKey instead.

Avoid scans on big tables in normal application paths.

Q14. How do you increase a counter attribute safely when many users update it at once? Fresher

Use an update expression with ADD (or SET with addition). DynamoDB applies it atomically on the server.

aws dynamodb update-item --table-name orders --key '{"pk":{"S":"PRODUCT#77"},"sk":{"S":"STATS"}}' --update-expression "ADD views :one" --expression-attribute-values '{":one":{"N":"1"}}' --return-values UPDATED_NEW

Output:

{"Attributes": {"views": {"N": "1043"}}}

views went up by one without reading the item first. No lost updates even with many writers.

Note: retries can count twice, so counters are not exact if a request is retried after a timeout.

Q15. What does --return-values do in put, update and delete calls? Fresher

It asks DynamoDB to return item data from the write:

  • NONE (default): nothing.
  • ALL_OLD: the item as it was before (useful on delete or put).
  • UPDATED_OLD or UPDATED_NEW: only the changed attributes, before or after (update-item).
  • ALL_NEW: the full item after the update.

Use it to avoid a second read, for example to get a new counter value or to log what was deleted.

Returning values does not cost extra read capacity for normal writes.

Q16. Which CloudWatch metrics do you check first when a DynamoDB table feels slow? Fresher
  • SuccessfulRequestLatency per operation (GetItem, Query, PutItem).
  • ThrottledRequests and ReadThrottleEvents / WriteThrottleEvents.
  • ConsumedReadCapacityUnits and ConsumedWriteCapacityUnits compared with provisioned or on-demand limits.
  • SystemErrors and UserErrors.

Quick check:

aws cloudwatch get-metric-statistics --namespace AWS/DynamoDB --metric-name ThrottledRequests --dimensions Name=TableName,Value=orders Name=Operation,Value=PutItem --start-time 2026-11-20T04:00:00Z --end-time 2026-11-20T05:00:00Z --period 300 --statistics Sum

Often "slow" is actually client-side: network, retries, or a missing connection reuse.

Q43. How do you delete a test table from the CLI, and what stops it? Fresher
aws dynamodb delete-table --table-name orders-test

Output:

"TableStatus": "DELETING"

The table and all its items are being deleted.

It fails if:

  • Deletion protection is on.
  • An IAM policy or SCP denies dynamodb:DeleteTable.
  • The table is a replica in a global table that must be removed through the global table settings.

On-demand backups are kept after the table is deleted, so you can still restore from them. Take one before deleting anything important.

3. Mid level questions

These questions check how you use the service in real projects. Interviewers expect the why, the how and one real example.

Q17. How do you update several attributes and remove one in a single update-item call? Mid level
aws dynamodb update-item --table-name orders --key '{"pk":{"S":"CUST#101"},"sk":{"S":"ORDER#2026-11-20#5001"}}' --update-expression "SET #st = :s, shippedAt = :d REMOVE couponCode" --expression-attribute-names '{"#st":"status"}' --expression-attribute-values '{":s":{"S":"SHIPPED"},":d":{"S":"2026-11-20T11:00:00Z"}}' --return-values ALL_NEW

status and shippedAt were set, and couponCode was removed, in one atomic write.

Update expression clauses: SET, REMOVE, ADD and DELETE (DELETE removes values from a set).

Q18. How do you append an element to a list attribute, and create the list if it does not exist? Mid level

Use list_append with if_not_exists:

aws dynamodb update-item --table-name orders --key '{"pk":{"S":"CUST#101"},"sk":{"S":"ORDER#2026-11-20#5001"}}' --update-expression "SET events = list_append(if_not_exists(events, :empty), :e)" --expression-attribute-values '{":e":{"L":[{"S":"packed"}]},":empty":{"L":[]}}'

"packed" is added to the end of the events list. If events did not exist, it starts as an empty list.

Be careful: items have a 400 KB size limit, so do not grow lists forever. Store long histories as separate items.

Q19. batch-write-item returned "UnprocessedItems". What does it mean and what do you do? Mid level
aws dynamodb batch-write-item --request-items file://batch.json

Output:

{"UnprocessedItems": {"orders": [{"PutRequest": {"Item": {...}}}]}}

Some writes were not done, usually because of throttling. The call itself did not fail.

What to do:

  • Retry only the unprocessed items, with exponential backoff.
  • Keep batches within limits (up to 25 put or delete requests per call).
  • SDKs and tools often do this loop for you, but scripts must handle it.

Ignoring UnprocessedItems is a common reason for "missing data" after an import.

Q20. How do you read many items by key in one call, and what is its limit? Mid level

Use batch-get-item:

aws dynamodb batch-get-item --request-items '{"orders":{"Keys":[{"pk":{"S":"CUST#101"},"sk":{"S":"PROFILE"}},{"pk":{"S":"CUST#102"},"sk":{"S":"PROFILE"}}]}}'

Output:

{"Responses": {"orders": [...]}, "UnprocessedKeys": {}}

Both items came back; nothing is left unprocessed.

Limits: up to 100 items and 16 MB per call. Items are returned in no fixed order, and missing keys are simply not returned. Handle UnprocessedKeys with retries, like UnprocessedItems.

Q21. What does ConditionalCheckFailedException tell you, and how do you see the current item when it happens? Mid level

It means the condition in your write was false, so DynamoDB made no change. It is expected behaviour, not a system error.

You can ask DynamoDB to return the current item when the condition fails:

aws dynamodb put-item --table-name orders --item file://order.json --condition-expression "attribute_not_exists(pk)" --return-values-on-condition-check-failure ALL_OLD

If the item already exists, the error includes the existing item, so your code can decide what to do without a second read.

These failed writes still consume write capacity.

Q22. What do these DynamoDB errors mean: ValidationException, ProvisionedThroughputExceededException, ItemCollectionSizeLimitExceededException? Mid level
  • ValidationException: the request is wrong, such as a missing key, a wrong type, an empty string key, a reserved word, or an item over 400 KB. Fix the request; retrying will not help.
  • ProvisionedThroughputExceededException (or ThrottlingException): too many requests for the capacity or a hot partition. Retry with backoff and fix capacity or key design.
  • ItemCollectionSizeLimitExceededException: on a table with a local secondary index, all items with one partition key value (an item collection) have reached the 10 GB limit.

Read the error type first; it tells you whether to fix code, retry, or redesign.

Q23. How do you export a DynamoDB table to S3, and why is it better than a scan? Mid level
aws dynamodb export-table-to-point-in-time --table-arn arn:aws:dynamodb:ap-south-1:111122223333:table/orders --s3-bucket orders-exports-111122223333 --export-format DYNAMODB_JSON

Output:

"ExportStatus": "IN_PROGRESS"

DynamoDB writes the table data to S3 from its continuous backups.

Why it is better:

  • It does not use table read capacity, so the application is not affected.
  • It needs point-in-time recovery turned on.
  • You can choose a full export or an incremental export of changes.

Then query the export with Athena or load it into a data lake.

Q24. How do you load a large CSV or JSON dataset into a new DynamoDB table? Mid level

Use import from S3:

aws dynamodb import-table --s3-bucket-source S3Bucket=orders-import-111122223333,S3KeyPrefix=2026-11/ --input-format CSV --table-creation-parameters '{"TableName":"orders-v2","AttributeDefinitions":[{"AttributeName":"pk","AttributeType":"S"},{"AttributeName":"sk","AttributeType":"S"}],"KeySchema":[{"AttributeName":"pk","KeyType":"HASH"},{"AttributeName":"sk","KeyType":"RANGE"}],"BillingMode":"PAY_PER_REQUEST"}'

DynamoDB creates a new table and loads the data without using write capacity.

Notes: it always creates a new table; bad rows are logged to CloudWatch Logs. It is usually cheaper and easier than a custom batch writer.

Q25. How do you create an on-demand backup and restore it with the CLI? Mid level
aws dynamodb create-backup --table-name orders --backup-name orders-before-migration

Output:

"BackupArn": "arn:aws:dynamodb:ap-south-1:111122223333:table/orders/backup/01732345678901-abcd1234"
aws dynamodb restore-table-from-backup --target-table-name orders-restored --backup-arn arn:aws:dynamodb:ap-south-1:111122223333:table/orders/backup/01732345678901-abcd1234

The backup was taken without affecting performance, and the restore creates a new table.

After restore, set up again: auto scaling, TTL, streams, alarms, tags and IAM references. Restores always go to a new table name.

Q26. How do you restore a table to a point in time 30 minutes ago? Mid level

Point-in-time recovery (PITR) must be on. Then:

aws dynamodb restore-table-to-point-in-time --source-table-name orders --target-table-name orders-1030 --restore-date-time 2026-11-20T10:30:00+05:30

A new table orders-1030 is created with the data as it was at 10:30 IST.

Use it after a bad deploy wrote wrong data: restore to a new table, compare, and copy back only the good items. PITR retention is configurable up to 35 days.

Q27. How do you find the hottest partition keys in a busy DynamoDB table? Mid level

Contributor Insights shows the most accessed and most throttled keys in a table or index.

aws dynamodb update-contributor-insights --table-name orders --contributor-insights-action ENABLE

You get graphs of the top partition keys (and partition plus sort keys) by traffic and throttling.

Use it to find hot keys, such as one celebrity product or a single "global counter" item that everyone updates. It has extra cost, so you can turn it on during investigations.

Q28. How do you attach a resource-based policy to a DynamoDB table? Mid level

DynamoDB tables (and streams) support resource-based policies, which help with cross-account access.

aws dynamodb put-resource-policy --resource-arn arn:aws:dynamodb:ap-south-1:111122223333:table/orders --policy file://orders-policy.json

Example statement: allow role arn:aws:iam::444455556666:role/reporting to run dynamodb:Query and dynamodb:GetItem on the table.

The other account's role can read the table directly, without assuming a role in your account (it still needs an identity policy in its own account).

Combine with conditions to limit access further.

Q29. What is warm throughput in DynamoDB, and when would you pre-warm a table? Mid level

Warm throughput shows how many reads and writes per second a table or index can handle instantly, based on its current partitions.

aws dynamodb describe-table --table-name orders --query "Table.WarmThroughput"

Output:

{"ReadUnitsPerSecond": 12000, "WriteUnitsPerSecond": 4000, "Status": "ACTIVE"}

Before a big launch or sale, you can raise warm throughput with update-table so the table is ready for the expected peak instead of scaling up during it. Pre-warming has a cost, so set it only for known events. Check current documentation for details.

Q30. How do you cap the maximum spend of an on-demand DynamoDB table? Mid level

Set maximum on-demand throughput for the table or a GSI:

aws dynamodb update-table --table-name orders --on-demand-throughput MaxReadRequestUnits=5000,MaxWriteRequestUnits=2000

Requests above these rates are throttled instead of scaling without limit.

Uses: protect against a bug or runaway job that writes millions of items, and keep cost predictable in dev and test. Set it with care in production, because throttling users is also costly.

Q31. What is DynamoDB zero-ETL integration? Mid level

Zero-ETL integrations copy DynamoDB data to analytics services automatically, without you building pipelines. Examples include integrations with Amazon OpenSearch Service (for search) and Amazon Redshift or SageMaker lakehouse targets (for analytics); check current docs for supported targets.

Benefits:

  • No custom Lambda or Glue jobs to maintain.
  • It reads from exports and streams, not by scanning the table, so the application is not slowed down.

Use it when you need search or reporting on DynamoDB data that DynamoDB itself is not good at.

Q32. How do you run a parallel scan, and when is it acceptable? Mid level

A parallel scan splits the table into segments, and several workers scan segments at the same time.

aws dynamodb scan --table-name orders --total-segments 4 --segment 0

(run the same command with --segment 1, 2 and 3 in other workers)

Each worker reads about a quarter of the table, so the full scan finishes faster.

Acceptable for one-off jobs such as backfills or migrations, ideally on a copy or during low traffic, with rate limiting so it does not throttle the application. For analytics, export to S3 instead.

Q33. How do you add a new GSI to a big existing table, and what should you watch? Mid level
aws dynamodb update-table --table-name orders --attribute-definitions AttributeName=gsi1pk,AttributeType=S --global-secondary-index-updates '[{"Create":{"IndexName":"gsi1","KeySchema":[{"AttributeName":"gsi1pk","KeyType":"HASH"}],"Projection":{"ProjectionType":"KEYS_ONLY"}}}]'

Watch:

  • The index status is CREATING while DynamoDB backfills existing items. Check with describe-table (IndexStatus and Backfilling).
  • Backfilling uses capacity; on provisioned tables, give the index enough write capacity.
  • Only items that have gsi1pk appear in the index.
  • Application code should not use the index until it is ACTIVE.
Q44. How do you run a PartiQL SELECT from the CLI, and how do you make sure it is not a scan? Mid level
aws dynamodb execute-statement --statement "SELECT total, status FROM orders WHERE pk = 'CUST#101' AND begins_with(sk, 'ORDER#')"

Output:

{"Items": [{"total": {"N": "1499"}, "status": {"S": "PAID"}}]}

Because the WHERE clause has the partition key with an equality condition, DynamoDB runs this as a query on one partition.

If you remove pk from WHERE, the same statement becomes a full table scan. To block that, deny dynamodb:PartiQLSelect unless it is a query (an IAM condition on dynamodb:FullTableScan can deny full scans).

4. Senior level and scenario questions

These questions check design thinking and troubleshooting. Think aloud. Say what you check first, what you change, and how you prevent it next time.

Q34. An import job shows success, but the item count is lower than expected. How do you investigate? Senior
  • If you used a custom batch writer: check that the code retried UnprocessedItems. Ignoring them loses data silently.
  • Duplicate keys in the source file: later rows overwrite earlier ones, so the count drops. Count distinct keys in the source.
  • Rows rejected for bad types or missing keys: check the import's CloudWatch error logs (for import from S3) or your script's error output.
  • ItemCount in describe-table is updated only about every six hours, so compare with a fresh count method.

Fix the process, then re-run idempotently (same keys overwrite safely).

Q35. A deploy added a GSI and the application's writes started throttling. Why? Senior
  • On provisioned tables, every write to the base table that affects the index also writes to the GSI. If the GSI has too little write capacity, it throttles, and this back-pressure throttles writes on the base table.
  • During creation, backfilling also uses capacity.
  • A GSI key with few distinct values (such as status = PENDING) creates a hot partition in the index.

Fix: give the GSI enough capacity (or use on-demand), choose a high-cardinality GSI key, project only needed attributes, and watch the GSI's own throttle metrics.

Q36. How do you migrate items to a new key design in a live table without downtime? Senior
  • Create the new table (or new GSI) with the new design.
  • Dual write: the application writes to both old and new structures.
  • Backfill old data with a controlled job (export to S3 and transform, or a rate-limited parallel scan), using conditional writes so newer data is not overwritten.
  • Or use DynamoDB Streams to copy changes continuously while the backfill runs.
  • Verify counts and sample items.
  • Switch reads to the new structure behind a feature flag, then stop writing to the old one.
  • Delete the old structure after a safe period.
Q37. A query in production returns fewer items than expected, with no error. What could be wrong? Senior
  • Pagination: the response stopped at 1 MB and returned LastEvaluatedKey, but the code did not loop.
  • A Limit parameter was set, which limits items read before filtering, so a filter can return very few items.
  • Eventually consistent read just after a write (or any read from a GSI, which is always eventually consistent).
  • The key condition uses the wrong case or prefix (begins_with is case-sensitive).
  • Items written with a slightly different key format by another service.

Check LastEvaluatedKey and ScannedCount in the raw response first.

Q38. How do you give a reporting team access to DynamoDB data without risking production performance? Senior
  • Export to S3 (full and incremental exports) and let them query with Athena or a warehouse.
  • Or use zero-ETL to Redshift or OpenSearch for near-real-time needs.
  • Never give them scan access on the live table; scans compete with the application for capacity.
  • Use IAM to limit them to the export bucket and catalog, with Lake Formation for column-level control if needed.
  • Remove or mask personal data in the export if they do not need it.
Q39. Your DynamoDB-backed API sees occasional latency spikes of hundreds of milliseconds. How do you find the cause? Senior
  • Compare client latency with DynamoDB's SuccessfulRequestLatency. If DynamoDB is fast, the problem is client-side.
  • Client side: new TCP and TLS connections (enable keep-alive and reuse clients), DNS lookups, retries after throttling (check SDK retry metrics), and cold starts in Lambda.
  • Server side: throttling on hot keys (Contributor Insights), large items, or big queries that read many items.
  • Set sensible SDK timeouts and retries so one slow request does not wait too long.
  • Trace with X-Ray to see where time is spent.
Q40. How would you protect a table from a buggy job that might delete or overwrite many items? Senior
  • Least privilege: the job's role gets only the actions it needs (for example no DeleteItem), and only on specific keys with dynamodb:LeadingKeys where possible.
  • Conditional writes so a write only happens if the data is in the expected state.
  • PITR on, so you can restore to a minute before the bug.
  • Deletion protection on the table.
  • Maximum on-demand throughput to limit how fast a runaway job can change data.
  • Test the job on a restored copy first.
  • Streams to an audit log, so you know exactly which items changed.
Q41. How do you run a safe bulk update of 50 million items, such as adding a new attribute? Senior
  • Avoid it if possible: handle the missing attribute in code (default value) and update items lazily when they are read or written.
  • If needed: export the table to S3, compute the changes with a batch job (Glue or EMR), and apply updates with a rate-limited worker using conditional updates.
  • Split the work by key ranges or segments, track progress, and make each update idempotent.
  • Watch throttling and latency for the live application, and pause automatically if they rise.
  • Do it in a test copy first to measure time and cost.
Q42. How do you find which code path is causing most of a table's write cost? Senior
  • Turn on ReturnConsumedCapacity in the application for sampled requests and log it with the operation name and code path.
  • Use CloudWatch metrics per operation (ConsumedWriteCapacityUnits by table and GSI) to see whether indexes multiply the cost.
  • Contributor Insights shows which keys get the most writes.
  • Look for large items: write cost grows with item size (each 1 KB counts), so rewriting a big item to change one field is expensive.
  • Look for unnecessary GSI updates when attributes that are part of an index change.

Fix the top contributor first: smaller items, fewer projected attributes, or splitting rarely changed data into separate items.

Q45. Your Lambda function writes to DynamoDB and sometimes saves the same order twice with different sort keys. How do you fix it? Senior

Why: the sort key includes a timestamp or random ID created inside the function, so a retry of the same event creates a new key instead of overwriting.

Fix:

  • Build keys from stable values in the event, such as the order ID from the source system.
  • Use a conditional put with attribute_not_exists(pk) so a second write with the same key fails safely.
  • Or use the Powertools idempotency utility keyed on the event ID.
  • Clean up existing duplicates with a one-off script that keeps the earliest item.
Q46. How do you test that your DynamoDB access patterns will scale before launch? Senior
  • Write down every access pattern with expected requests per second and item sizes.
  • Run a load test against a copy of the table with realistic key distribution (not the same key every time, and not perfectly random either).
  • Watch throttling, latency and Contributor Insights for hot keys.
  • Test peak events, such as a flash sale on one product.
  • Check GSIs separately; they have their own capacity and hot keys.
  • Pre-warm with warm throughput if the launch peak is known.
Q47. You must delete all items for one customer to meet a data deletion request. How do you do it reliably? Senior
  • Query by the customer's partition key (and any GSIs that hold their data) to find all items, with pagination.
  • Delete with batch-write-item in groups of up to 25, retrying unprocessed items.
  • Check other tables and copies: exports in S3, backups (follow your retention policy), analytics copies, caches and logs.
  • Log the deletion (without the personal data) for audit.
  • Verify with a final query that returns zero items.

Design tip: keep all of a customer's items under keys that include the customer ID, so deletion is easy.

Q48. A DynamoDB transaction fails with TransactionCanceledException. How do you find which part failed? Senior

The error includes CancellationReasons, one per item in the transaction, in the same order as your request.

Output:

"CancellationReasons": [{"Code": "None"}, {"Code": "ConditionalCheckFailed", "Message": "The conditional request failed"}, {"Code": "None"}]

The second action's condition was false (for example stock was already zero), so the whole transaction was cancelled and nothing was written.

Other codes include TransactionConflict (another request was changing the same item) and ThrottlingError. Retry conflicts with backoff; handle condition failures as business logic.

Q49. How do you move a table from one AWS account to another? Senior

Options:

  • Export to S3 (from PITR) in the source account, give the target account access to the bucket, then use import from S3 to create a new table in the target account.
  • AWS Backup cross-account copy, then restore in the target account.
  • For ongoing changes during cutover, stream changes (Streams with a consumer, or Kinesis Data Streams for DynamoDB) to write into the target table, then switch the application.

Re-create settings in the target: indexes (import can create GSIs), TTL, streams, alarms, policies. Test a full rehearsal first.

Q50. An application reads a GSI right after writing an item and sometimes gets nothing. How do you fix it? Senior

GSIs are updated asynchronously, so reads from a GSI are always eventually consistent. Right after a write, the item may not be in the index yet.

Fix options:

  • Read the base table with a strongly consistent get-item when you need the item immediately (you know its key).
  • Return the written data to the caller directly instead of reading it back.
  • Design the UI to accept a small delay, or retry the index read briefly.

Strongly consistent reads are not available on GSIs, so this is a design choice, not a setting.

5. Frequently asked questions

Do I need to know the low-level JSON format with "S" and "N"?

Yes, for the CLI. The AWS CLI and low-level APIs use typed values like {"S": "ord-1"}. SDK document clients (for example lib-dynamodb or boto3's Table resource) hide this, but interviews often show the raw form.

Is PartiQL easier than expressions?

For people who know SQL, PartiQL looks familiar. But it uses the same rules underneath: without the key, a SELECT becomes a scan.

What should I practise?

Write items, update a counter, run a query with pagination, export a table to S3 and query the export with Athena.

6. Quick revision

  • Query needs the partition key; filters run after items are read.
  • Use ExpressionAttributeNames (#n) for reserved words such as name, status and date.
  • Always loop on LastEvaluatedKey and UnprocessedItems.
  • ConditionalCheckFailedException means your condition was false, not that DynamoDB failed.
  • Export to S3 does not use table capacity; it needs point-in-time recovery on.

This page is one part of the complete AWS interview question set. Open the full list here: All 2052 AWS interview questions.