Subchapter 34.3
references/common-pitfalls.mdMarkdown3 KBView on GitHub
API operation names and IAM action names frequently differ. Always query the service authorization reference.
Wrong — the correct action is dynamodb:Query.
Some operations require multiple IAM actions. For example, dynamodb:BatchExecuteStatement requires dynamodb:PartiQLDelete, dynamodb:PartiQLInsert, dynamodb:PartiQLSelect, and dynamodb:PartiQLUpdate.
{
"Action": "s3:GetObject",
"Resource": "*"
}Too broad. Specify bucket and object paths: arn:aws:s3:::my-bucket/*.
ForAnyValue and ForAllValues MUST only be used with array-typed condition keys.
Check the type using the service reference ConditionKeys array:
ArrayOfString, ArrayOfARN, ArrayOfNumeric
aws:TagKeys, dynamodb:Attributes, dynamodb:LeadingKeysString, Bool, ARN, Numeric
dynamodb:EnclosingOperation, dynamodb:FullTableScanForAnyValue evaluates to FALSE when the context key does not exist. Deny statements using ForAnyValue will not block requests when the key is missing.
❌ Incorrect:
{
"Effect": "Deny",
"Principal": "*",
"Action": ["s3:GetObject", "s3:PutObject"],
"Resource": "arn:aws:s3:::my-bucket/*",
"Condition": {
"ForAnyValue:StringNotLike": {
"aws:VpceOrgPaths": "o-abcdefg/r-12345/ou-123456/*"
}
}
}✅ Correct — add a separate Null-check statement:
{
"Effect": "Deny",
"Principal": "*",
"Action": ["s3:GetObject", "s3:PutObject"],
"Resource": "arn:aws:s3:::my-bucket/*",
"Condition": {
"ForAnyValue:StringNotLike": {
"aws:VpceOrgPaths": "o-abcdefg/r-12345/ou-123456/*"
}
}
},
{
"Effect": "Deny",
"Principal": "*",
"Action": ["s3:GetObject", "s3:PutObject"],
"Resource": "arn:aws:s3:::my-bucket/*",
"Condition": {
"Null": { "aws:VpceOrgPaths": "true" }
}
}ForAllValues evaluates to TRUE when the context key does not exist. Allow statements using ForAllValues will grant access when the key is missing.
❌ Incorrect:
{
"Effect": "Allow",
"Action": "s3:PutObject",
"Resource": "*",
"Condition": {
"ForAllValues:StringEquals": { "aws:TagKeys": "a" }
}
}✅ Correct — require the key to exist:
{
"Effect": "Allow",
"Action": "s3:PutObject",
"Resource": "*",
"Condition": {
"Null": { "aws:TagKeys": "false" },
"ForAllValues:StringEquals": { "aws:TagKeys": "a" }
}
}ForAllValues in Allow statements is risky. If you must use it, always combine with Null: false.
For identity policies, most policies only need Actions and Resources. Add conditions only when:
iam:DeleteUser)Resource policies more commonly use conditions (VPC endpoints, source IPs, secure transport).