After a refactor that moved writes to a new table, every invocation of a Lambda function fails with this error:AccessDeniedException: User: arn:aws:sts::111122223333:assumed-role/orders-fn-role/orders-fn
is not authorized to perform: dynamodb:PutItem on resource:
arn:aws:dynamodb:us-east-1:111122223333:table/Orders-v2
because no identity-based policy allows the dynamodb:PutItem actionThe developer's own IAM user can write to Orders-v2 from the AWS CLI. What should the developer do?
Choose one.
An AccessDenied message names the principal, the action, the resource and the type of policy that is missing.
The principal is assumed-role/orders-fn-role, which is the function's execution role, and the message says no identity-based policy allows dynamodb:PutItem on Orders-v2. After the refactor the role's policy most likely still lists the old table ARN. Adding the new ARN to the role fixes it. The developer's own permissions do not matter, because Lambda uses the execution role's credentials. A resource policy for the Lambda service principal would not match a role session.
- Read the principal in the error: it is the execution role session.
- Read the action and resource: PutItem on the new table ARN.
- Note the reason: no identity-based policy allows it.
- Add the new table ARN to the execution role's policy.
Exam tip: Fix the policy of the principal named in the AccessDenied message, which for Lambda is the execution role.
DVA-C03 Root Cause Analysis: Lambda and API Errors, Logs Insights, X-Ray, Deployment Logs and AI Troubleshooting — the lesson that teaches this.