A user edits the app so that it calls GetItem for a note stored under another user's partition key.
What is the result, and why?
Choose one answer.
AA. The request succeeds for reads but is denied for writes, because the condition applies only to PutItem and UpdateItem.
BB. The request is denied, because the condition limits each caller to items whose partition key equals the caller's own identity ID.
CC. The request succeeds, because DynamoDB applies the condition only to attributes named in a projection expression.
DD. The request is denied, because the condition restricts which attributes of an item the caller may read or write.
Show the answer and explanation
Answer: B
A. Wrong: The condition sits on the one statement that allows all four actions, so it applies to reads as well as writes. Reads of another user's partition key do not match and are not allowed. Learn more: IAM conditions for DynamoDB (opens in a new tab)
B. Right: Correct. The dynamodb:LeadingKeys key holds the partition key values a request touches. The policy variable resolves to the caller's identity ID, so only that user's partition is allowed. Learn more: Item-level access by Cognito ID (opens in a new tab)
C. Wrong: Attribute-level limits use a different key, dynamodb:Attributes. LeadingKeys is checked against the partition key values that the request targets, whether or not a projection is used. Learn more: IAM conditions for DynamoDB (opens in a new tab)
D. Wrong: The result is a denial, but the reason is wrong. Controlling which attributes can be accessed is done with dynamodb:Attributes, whereas LeadingKeys limits the partition key values. Learn more: IAM conditions for DynamoDB (opens in a new tab)
Explanation
dynamodb:LeadingKeys matches the partition key values in a request, and ${cognito-identity.amazonaws.com:sub} becomes the caller's own identity ID when the policy is evaluated. A request for another user's partition key therefore falls outside what the statement allows and is denied, whichever of the four actions is used. Attribute limits are a separate condition key.
Want more on Secrets and sensitive data? The 5 full-length practice sets have 15 more Secrets and sensitive data questions, 390 in all, none of them in the free exam. One payment of $14.99, no subscription. See the practice sets →