Question

Difficulty: MediumData Store Operations with Amazon DynamoDB

A developer is building a collaborative project management application where team members can assign tasks to each other. The application stores task details in an Amazon DynamoDB table with `ProjectIDProjectID` as the partition key and `TaskIDTaskID` as the sort key.

The developer needs to implement two requirements:
1. Retrieve all tasks within a specific project that have a status of 'In Progress'.
2. Retrieve all tasks across all projects assigned to a specific team member using their `AssigneeIDAssigneeID`.

Additionally, the developer must initialize the AWS SDK DynamoDB client securely within an AWS Lambda function that executes these queries.

Which two actions should the developer take to meet these requirements efficiently and securely? (Select two.)

  1. Perform a `Query` operation on the base table using a `KeyConditionExpression` on `ProjectIDProjectID` and a `FilterExpression` on the status attribute.Answer
  2. Create a Global Secondary Index (GSI) with `AssigneeIDAssigneeID` as the partition key, and perform a `Query` operation against this GSI.Answer
  3. C
    Perform a `Scan` operation on the base table with a `FilterExpression` on `AssigneeIDAssigneeID` to retrieve tasks assigned to a specific team member.
  4. D
    Pass hardcoded IAM User access keys and secret access keys directly to the SDK DynamoDB client constructor within the Lambda function code.
  5. E
    Create a Local Secondary Index (LSI) with `AssigneeIDAssigneeID` as the partition key to retrieve tasks across all projects.

Answer

To retrieve tasks by project status, perform a Query operation on the base table with a KeyConditionExpression on the partition key and a FilterExpression on the status. To retrieve tasks by assignee across all projects, create a Global Secondary Index with the assignee ID as the partition key and perform a Query against it. Additionally, initialize the DynamoDB client without hardcoding credentials, allowing it to use the Lambda execution role.
The correct approach is to use a Query operation on the base table for project-specific queries since the partition key is known. To query across different partitions (projects) by assignee, a Global Secondary Index is required because it allows a different partition key. For security, the DynamoDB client should rely on the Lambda function's IAM execution role instead of hardcoded credentials.

Step-by-Step Solution

1
Analyze the query pattern for project tasks.
Querying by `ProjectIDProjectID` uses the base table's partition key, so a `Query` operation with a `KeyConditionExpression` and a `FilterExpression` is the most efficient choice.
This avoids scanning the entire table and limits the read to a single partition.
2
Analyze the query pattern for assignee tasks across all projects.
Since the query needs to span multiple projects (different partition keys), a Global Secondary Index (GSI) must be created with `AssigneeIDAssigneeID` as the partition key.
Local Secondary Indexes require the same partition key as the base table, so only a GSI can query across different projects.
3
Evaluate security best practices for SDK client initialization in AWS Lambda.
Initialize the client using the default credential provider chain, which automatically uses the Lambda function's IAM execution role.
This avoids hardcoding credentials in the code, which is a severe security vulnerability.

Key Concept

Data Store Operations with Amazon DynamoDB
Rate this question