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 `` as the partition key and `` 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 ``.
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.)
- Perform a `Query` operation on the base table using a `KeyConditionExpression` on `` and a `FilterExpression` on the status attribute.Answer
- Create a Global Secondary Index (GSI) with `` as the partition key, and perform a `Query` operation against this GSI.Answer
- CPerform a `Scan` operation on the base table with a `FilterExpression` on `` to retrieve tasks assigned to a specific team member.
- DPass hardcoded IAM User access keys and secret access keys directly to the SDK DynamoDB client constructor within the Lambda function code.
- ECreate a Local Secondary Index (LSI) with `` 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
Key Concept
Data Store Operations with Amazon DynamoDB