AWS Certified CloudOps Engineer Associate SOA-C03 [2026]

Create and Query a DynamoDB Table with AWS CLI and Lambda

Learn how to create a DynamoDB table, batch-load JSON data, grant Lambda read access, and test key-based and scan-based queries.

AWS Certified CloudOps Engineer Associate SOA-C03 [2026]AWS Certified CloudOps Engineer Associate SOA-C03 [2026]Updated Sep 1, 2026
Study options
WatchComing later
ListenComing later
ReadAvailable
ReviewComing later

Study guide

Technical reference and lesson notes

Purpose of This Lesson

This hands-on lesson demonstrates an end-to-end DynamoDB workflow:

  • Create a DynamoDB table with the correct table name and partition key.
  • Load multiple records from a JSON file using the AWS CLI and CloudShell.
  • Grant an AWS Lambda function permission to read from DynamoDB.
  • Use Lambda test events to retrieve individual items, retrieve multiple items, and scan records using application logic.
  • Clean up the resources after testing.

The exercise is especially useful for recognizing how serverless database storage, IAM permissions, CLI operations, and Lambda-based data access fit together.

Key Concepts

DynamoDB as a NoSQL Service

Amazon DynamoDB is a fully managed, serverless NoSQL database. It supports key-value data and document-style data rather than the fixed relational structures used by SQL databases.

Important characteristics include:

  • No database servers or instance types to deploy and manage.
  • Automatic horizontal scaling through partitions managed by AWS.
  • Data replicated across multiple Availability Zones.
  • Millisecond-level latency for normal access patterns.
  • SSD-backed storage.
  • Flexible item attributes, meaning different records do not need to contain exactly the same attributes.

DynamoDB tables can also use Global Tables to synchronize data across AWS Regions. Global Tables support a multi-Region, multi-master design.

Partition Key

The sample table is named product catalog, using the exact capitalization and spelling supplied by the exercise files. Its partition key is ID, with a capital I and D, and its data type is Number.

Every item must have a unique value for this partition key. In the sample data, values such as 101 and 201 identify individual products. A product code or customer ID could serve a similar purpose in another table if it uniquely identifies each item.

The table definition must match the data and the code. A mismatch in table name, key name, capitalization, or key type can cause table creation, writes, or Lambda queries to fail.

Items and Attributes

Each DynamoDB item represents a record. The sample records contain attributes such as:

  • ID: the numeric partition key.
  • title: a string containing a product or book title.
  • ISPN: a string attribute.
  • authors: a list of authors.

Unlike a relational table, DynamoDB does not require every item to have the same set of non-key attributes. This schema flexibility is useful for document-style data, but applications still need to understand which attributes are present before attempting to use them.

Batch Writes

The exercise uses the DynamoDB BatchWriteItem API through the AWS CLI. The JSON file contains multiple PutRequest entries, allowing the records to be submitted in one API request rather than one write request at a time.

After the command completes, an UnprocessedItems result with no items indicates that there were no writes left to retry in this exercise. In production workflows, applications should still account for the possibility of unprocessed items and retry them appropriately.

Lambda Data Access

The Lambda function named DDB test is written in Python. Its code references the same DynamoDB table name used during table creation and implements several test behaviors:

  • Retrieve an item by ID 101.
  • Retrieve an item by ID 201.
  • Retrieve three items in a batch.
  • Scan using a category and minimum-price condition, returning items such as book 102 and book 103 in the exercise.

Lambda does not automatically have access to DynamoDB. Its execution role must receive an appropriate policy. For this read-only exercise, the role is given DynamoDB read-only access rather than write permissions.

DynamoDB and Lambda Implementation Workflow

1. Inspect the Exercise Files

Open both files in the course download’s Amazon DynamoDB folder:

  • product catalog.json: contains the table’s batch write requests.
  • Dynamo DB code events: contains the Lambda function code and test event JSON.

Before creating the table, verify the exact table name, partition-key name, key type, and attribute names used by the files and code.

2. Create the Table

In the DynamoDB console:

  1. Choose Create table.
  2. Enter the exact table name from the data file: product catalog.
  3. Set the partition key to ID.
  4. Select Number as the key type.
  5. Leave the remaining capacity and performance settings at their defaults for this test.
  6. Create the table.

DynamoDB manages the underlying partitions and replication. You do not select individual partitions for this exercise.

3. Upload the Data File to CloudShell

Open AWS CloudShell and use Actions → Upload file to upload the batch data JSON file. The file must be available in the current CloudShell filesystem before running the CLI operation.

Use the AWS CLI DynamoDB batch-write-item operation with the uploaded request-items JSON file. The request-items file supplies the PutRequest records that will be inserted into the table.

After execution, inspect the result. An empty UnprocessedItems object indicates that the submitted records were processed successfully in this exercise.

4. Validate the Items

In the DynamoDB console, open Explore items, select the table, and scan the table. Confirm that the expected product records and their attributes are present.

The records may not all have identical non-key attributes. That is expected for DynamoDB’s flexible NoSQL item model.

5. Create and Configure the Lambda Function

Create a Lambda function with these exercise settings:

  • Function name: DDB test
  • Runtime: Python
  • Default creation settings, unless the environment requires a different execution-role choice

Replace the default function code with the Python code from the exercise file, then choose Deploy.

Next, configure the function’s execution role:

  1. Open Configuration → Permissions.
  2. Select the Lambda execution role.
  3. Choose Add permissions → Attach policies.
  4. Attach the required DynamoDB read-only policy for the exercise.

Only read access is required because the function retrieves data but does not write to the table.

6. Run Lambda Test Events

Create a Lambda test event named DDB test. Replace the default event JSON with the supplied test events and deploy or save the event before testing.

The demonstrated test patterns are:

  • A single-item lookup for ID 101, which returns the record for book 101.
  • A single-item lookup for ID 201, which returns the record for bike 201.
  • A batch lookup for three IDs, which returns three records in one operation.
  • A scan using a category and minimum price of 10, which returns book 102 and book 103 in the sample data.

These event patterns illustrate how the same Lambda function can expose multiple application-level data retrieval behaviors.

7. Clean Up

When the exercise is complete, delete the DynamoDB table and the Lambda function. Removing temporary lab resources prevents them from remaining in the account after testing.

Exam- or Assessment-Relevant Takeaways

For AWS Certified CloudOps Engineer Associate preparation, focus on recognizing the operational decisions demonstrated by this lab:

  • DynamoDB is serverless and does not require EC2 instances or database servers.
  • DynamoDB scales horizontally through AWS-managed partitions rather than by changing a server instance type.
  • A partition key must be defined with the correct name and data type, and its value must uniquely identify each item in this exercise.
  • Table names, key names, and capitalization must match the application code and input data.
  • BatchWriteItem is appropriate when multiple PutRequest items are supplied as one batch request.
  • Lambda requires IAM permissions through its execution role before it can read DynamoDB data.
  • Grant read-only permissions when the function only retrieves data; do not grant write permissions unnecessarily.
  • DynamoDB supports flexible item attributes because it is a NoSQL document/key-value store.
  • Global Tables provide cross-Region synchronization with a multi-Region, multi-master model.
  • DynamoDB provides millisecond-level latency; DynamoDB Accelerator can reduce access latency to microseconds and uses instances.

These are study takeaways from the demonstrated workflow, not claims about a guaranteed exam question or an exhaustive official exam objective.

Tool / Feature Decision Guide

RequirementAppropriate choiceReason
Store flexible key-value or document-style records without managing database serversDynamoDBIt is a fully managed, serverless NoSQL service.
Submit several item writes from a prepared JSON fileAWS CLI batch-write-item with PutRequest entriesMultiple writes can be submitted through one batch API request.
Retrieve one known recordLambda logic using the item’s IDThe partition key identifies the target item.
Retrieve several known recordsLambda batch-get behaviorA batch lookup can request multiple IDs together.
Find records based on a broader condition such as category and minimum priceScan-based logic in the sample functionThe exercise’s final event searches by category and price rather than one known ID.
Run application code that reads the tableLambda with an execution-role read policyLambda must be explicitly authorized to access DynamoDB.
Need synchronized tables across RegionsDynamoDB Global TablesGlobal Tables support multi-Region, multi-master replication.
Need lower latency than normal DynamoDB millisecond accessDynamoDB Accelerator (DAX)The lecture identifies DAX as providing microsecond-level latency and using instances.

Common Traps / Misconceptions

  • Treating DynamoDB like a relational database: Items do not need identical non-key attributes, and the service is not organized around SQL tables with fixed rows and columns.
  • Using the wrong key spelling or capitalization: ID is not interchangeable with id; the table definition, JSON data, and Lambda code must agree.
  • Assuming the partition key can repeat: In this exercise, each item requires a unique numeric ID value.
  • Expecting to choose or manage partitions directly: DynamoDB manages partitioning and replication for the table.
  • Forgetting Lambda permissions: A function can be correctly coded and still fail to read the table if its execution role lacks DynamoDB read access.
  • Granting broader permissions than needed: The function only reads data, so read-only access is the appropriate permission scope for this lab.
  • Confusing a successful request with complete processing: The batch response should be checked for UnprocessedItems; an empty object indicates none remained in this exercise.
  • Assuming a batch request is a relational transaction: Batch writing is a way to submit multiple item requests; the lesson does not establish relational transaction behavior.
  • Leaving lab resources running: Delete the table and Lambda function when finished.

Real-World Engineer / Analyst Notes

  • Treat the table name and key schema as an interface contract between infrastructure, data-loading scripts, and application code.
  • Validate input JSON before running a batch write, especially when records contain nested lists such as authors.
  • Build retry handling around unprocessed batch items in production code rather than assuming every batch write is permanently complete after one response.
  • Keep Lambda IAM permissions narrowly scoped to the operations the function actually performs.
  • Use known-key retrieval when the access pattern has a specific partition-key value. Broader scan-style searches can be useful for a demonstration, but engineers should evaluate access patterns and performance carefully before using them as a general application design.
  • Test both successful reads and failure conditions such as a missing item, an incorrect table name, an incorrect key type, or insufficient role permissions.
  • The console is useful for validating the loaded data, while CloudShell and the AWS CLI make the loading process repeatable and scriptable.
  • Clean up temporary tables, functions, and policies or role attachments after a lab to avoid operational clutter and unintended resource retention.

Quick Reference Summary

  • Service: Amazon DynamoDB
  • Database model: Serverless NoSQL key-value and document store
  • Sample table: product catalog
  • Partition key: ID, type Number
  • Data load: AWS CLI DynamoDB batch-write-item using a JSON request-items file
  • Validation: DynamoDB console → Explore items
  • Lambda function: DDB test, written in Python
  • Required access: DynamoDB read-only permission on the Lambda execution role
  • Sample tests: Get ID 101, get ID 201, batch get three items, and scan with minimum price 10
  • Performance: Millisecond-level DynamoDB access; DAX can provide microsecond-level latency
  • Multi-Region option: DynamoDB Global Tables
  • Cleanup: Delete the DynamoDB table and Lambda function

Flashcards

Q: A Lambda function uses a table name that differs from the name used during table creation by capitalization only. What should you check first?
A: Check that the table name matches exactly, including capitalization. The Lambda code, table, and data-loading process must use the same name.

Q: Which DynamoDB key is configured in this exercise, and what data type does it use?
A: The partition key is ID, with uppercase I and D, and its type is Number.

Q: Why must each sample item’s ID be unique?
A: The partition key identifies each item in the exercise. Duplicate key values would not represent separate uniquely addressable records in the intended table design.

Q: You need to load many PutRequest records from a prepared JSON file. Which AWS CLI operation should you choose?
A: Use DynamoDB batch-write-item with the request-items JSON file. It submits multiple item write requests through a batch API call.

Q: What does an empty UnprocessedItems object indicate after the batch write?
A: No items remain unprocessed in the returned response, so the batch completed successfully for the demonstrated operation.

Q: How does DynamoDB differ from a relational SQL database in the sample data model?
A: DynamoDB is a NoSQL key-value/document store, so records can have different non-key attributes instead of conforming to one fixed relational row schema.

Q: A Lambda function only retrieves DynamoDB records and never writes them. What permission scope should be preferred?
A: Grant the Lambda execution role the required DynamoDB read-only access rather than write or broader permissions.

Q: What is the likely cause if Lambda code is correct but reads from DynamoDB fail with an authorization problem?
A: The Lambda execution role is missing the required DynamoDB read permission or has the wrong policy attached.

Q: When would a single-item lookup be preferable to the sample scan behavior?
A: Use a single-item lookup when the required record is known by its partition-key value, such as ID 101 or 201.

Q: What retrieval patterns are demonstrated by the Lambda test events?
A: The function performs individual ID lookups, a batch lookup for three items, and a scan using category and minimum-price criteria.

Q: What does DynamoDB manage instead of requiring the engineer to select database partitions?
A: DynamoDB automatically manages partitions, including horizontal scaling and replication across multiple Availability Zones.

Q: When would Global Tables be relevant?
A: Use Global Tables when tables need to be synchronized across AWS Regions. The lecture describes them as multi-Region and multi-master.

Q: How does DynamoDB Accelerator differ from standard DynamoDB access in the lecture?
A: DAX is used when even lower latency is needed, reducing access to microseconds; unlike DynamoDB’s serverless table service, DAX uses instances.

Q: What should be done with the lab resources after testing?
A: Delete the DynamoDB table and the Lambda function so temporary resources are not left in the account.

Practice Questions

Question 1

A Python Lambda function is deployed successfully, but its test invocation cannot read from the product catalog table and returns an access-denied error. The function’s table name and key usage are correct. What is the best next step?

A. Change the DynamoDB partition key from Number to String
B. Attach the required DynamoDB read-only policy to the Lambda execution role
C. Upload the JSON file to CloudShell again
D. Add an EC2 instance to host the database

Correct answer: B

The decisive clue is the access-denied error. Lambda needs DynamoDB permissions through its execution role; the service does not require an EC2 database host.

Question 2

An engineer creates a table with partition key id, but the supplied JSON file and Lambda code use ID as the key. What is the most likely problem?

A. DynamoDB automatically converts both names to the same key
B. The table will use a vertical scaling model
C. The data and application code do not match the table schema
D. Lambda cannot invoke Python functions against DynamoDB

Correct answer: C

DynamoDB key names are part of the table and application contract. The capitalization difference means the table schema does not match the input data and Lambda code.

Question 3

A lab needs to insert all records described by a JSON file containing multiple PutRequest entries. The engineer wants to avoid issuing one CLI write command for every item. Which option best fits the demonstrated workflow?

A. DynamoDB batch-write-item using the request-items file
B. DynamoDB Global Tables
C. Lambda execution-role configuration
D. DAX instance creation

Correct answer: A

The lecture uses the AWS CLI batch-write-item operation to submit multiple item writes from the JSON request file.

Question 4

A Lambda test event must retrieve the record for product ID 201, and the table uses numeric ID as its partition key. Which approach is most appropriate?

A. Use a single-item lookup for ID 201
B. Delete and recreate the table with no partition key
C. Use Global Tables to replicate the record
D. Attach DynamoDB write-only permissions

Correct answer: A

The requested record is known by its partition-key value, so the demonstrated single-item lookup by ID is the appropriate access pattern.

Question 5

After running the batch write command, the response contains an empty UnprocessedItems object. What does this tell the engineer in the context of the lab?

A. The table has been deleted
B. No submitted items remain unprocessed in the response
C. The Lambda function has been granted write access
D. The table has automatically become a relational database

Correct answer: B

An empty UnprocessedItems result indicates that no items were left for processing in the demonstrated batch operation. The engineer should still validate the records in DynamoDB Explore items.

WordPress Metadata

Suggested Slug:
create-query-dynamodb-table-cli-lambda

Meta Description:
Learn how to create a DynamoDB table, batch-load JSON data, grant Lambda read access, and test key-based and scan-based queries.

Tags:
AWS DynamoDB, AWS Lambda, AWS CLI, CloudShell, NoSQL databases, DynamoDB tables, IAM permissions, BatchWriteItem, DynamoDB queries, AWS CloudOps