AWS Certified Developer – Associate — Question 257
A company is developing a serverless ecommerce web application. The application needs to make coordinated, all-or-nothing changes to multiple items in the company's inventory table in Amazon DynamoDB.
Which solution will meet these requirements?
Answer options
- A. Enable transactions for the DynamoDB table. Use the BatchWriteItem operation to update the items.
- B. Use the TransactWriteItems operation to group the changes. Update the items in the table.
- C. Set up a FIFO queue using Amazon SOS. Group the changes in the queue. Update the table based on the grouped changes.
- D. Create a transaction table in an Amazon Aurora DB cluster to manage the transactions. Write a backend process to sync the Aurora DB table and the DynamoDB table.
Correct answer: B
Explanation
The correct answer is B because the TransactWriteItems operation is specifically designed for making coordinated changes to multiple items in DynamoDB, ensuring all-or-nothing execution. Option A is incorrect as BatchWriteItem does not support transactions; it can fail part of the operation. Options C and D involve additional complexity and do not natively support the required atomicity in DynamoDB.