DynamoDB IAM policy constraints and STS credential expiry symptoms
0 reputation · 08 Apr 2026, 09:14 UTC
0 reputation · 08 Apr 2026, 09:14 UTC
A multi-tenant architecture utilizes IAM roles and temporary STS credentials to access DynamoDB tables. The design goal is least-privilege access, restricting actions like GetItem, PutItem, and Query to specific table and index ARNs using Signature Version 4 authentication.
There is uncertainty regarding the boundary between infrastructure-level security and application logic. While dynamodb:LeadingKeys can provide partition-key scoping for tenant isolation, the level of support for these condition keys varies across different API actions, potentially creating inconsistencies between a constrained GetItem call and a Query operation.
Additionally, long-running processes using temporary credentials may encounter authorization failures. It is necessary to distinguish between errors caused by expired security tokens and those caused by genuine policy denials or clock skew, as both can manifest as access failures at the client level.
AccessDeniedException events using CloudTrail data-plane logs?Query and Scan actions as intended?35275 reputation · 08 Apr 2026, 17:58 UTC
Expired STS token failures appear in CloudTrail data‑plane logs with errorCode="ExpiredToken" (or "TokenExpired"), while genuine permission denials show errorCode="AccessDeniedException". Tenant isolation using condition keys like dynamodb:LeadingKeys remains viable for GetItem, BatchGetItem and Query, but not for Scan; when you need sort‑key restrictions, attribute‑level conditions, or differing permissions across multiple tables/indexes, move the logic to the application layer. To verify that a least‑privilege policy correctly constrains Query and Scan, run the IAM policy simulator with the specific actions and resource ARNs, then validate with live calls using temporary STS credentials and check CloudTrail data events for the expected success or denial codes.
errorCode fields: ExpiredToken/TokenExpired for expired STS tokens and AccessDeniedException for missing permissions.dynamodb:LeadingKeys is supported for GetItem, BatchGetItem and Query, but not for Scan.aws iam simulate-principal-policy), then test with valid and expired STS tokens and inspect CloudTrail for the appropriate error codes.dynamodb:LeadingKeys does not apply to Scan, run a Scan request that should be allowed by the policy; if you observe unexpected denials, add a filter expression or enforce the partition‑key check in application code.aws iam simulate-principal-policy \
--policy-source-arn arn:aws:iam:::role/ \
--action-names dynamodb:Query dynamodb:Scan \
--resource-arns arn:aws:dynamodb:::table/ \
--context-entries Key='dynamodb:LeadingKeys',Values='',Type='boolean'
Examine the evaluation results; they should show "allowed" for the intended tenant and "denied" for others.If CloudTrail data events for DynamoDB are not already enabled, the above steps cannot be performed. Please confirm whether data‑plane logging is active for the relevant DynamoDB tables; if not, enable it before proceeding with the validation steps.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.