Bird
0
0

You need to allow a Lambda function to write to a DynamoDB table only if the item's partition key starts with 'user#'. How can you enforce this in the IAM policy?

hard🚀 Application Q9 of 15
DynamoDB - Security and Access Control
You need to allow a Lambda function to write to a DynamoDB table only if the item's partition key starts with 'user#'. How can you enforce this in the IAM policy?
ASet Resource ARN to 'arn:aws:dynamodb:::table/user#*'.
BUse a Condition with StringLike on 'dynamodb:LeadingKeys' set to 'user#*'.
CAllow all writes and filter in the Lambda code.
DUse Effect Deny for keys not starting with 'user#'.
Step-by-Step Solution
Solution:
  1. Step 1: Use Condition to restrict partition keys

    The 'dynamodb:LeadingKeys' condition key can restrict access based on partition key patterns.
  2. Step 2: Apply StringLike operator for prefix matching

    Using StringLike with 'user#*' matches any key starting with 'user#'.
  3. Final Answer:

    Use a Condition with StringLike on 'dynamodb:LeadingKeys' set to 'user#*'. -> Option B
  4. Quick Check:

    Condition with StringLike restricts keys by prefix [OK]
Quick Trick: Use StringLike on dynamodb:LeadingKeys for prefix match [OK]
Common Mistakes:
MISTAKES
  • Trying to use wildcards in Resource ARN
  • Allowing all writes without restriction
  • Using Deny instead of Condition for prefix

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More DynamoDB Quizzes