opensite-ai/opensite-skills / aws-iam
aws-iam
VerifiedProvides verified corrections for IAM behaviors that AI agents frequently get wrong — policy evaluation edge cases, trust policy gotchas, STS session limits, Organizations quirks, and SAML/MFA specifics. Also provides structured workflows for IAM role management and baseline policy generation from application source code or a Terraform plan JSON. Covers condition operator safety (ForAnyValue/ForAllValues with Null checks), bucket policy deny patterns (VPC endpoint restrictions, org paths), confused deputy protection, and service role creation for AWS services (Glue, CloudTrail, Lambda, ECS, etc.) with aws:SourceAccount/aws:SourceArn trust conditions. Applies when creating IAM roles, writing IAM or bucket policies, generating policies from application source code or a Terraform plan JSON, working with STS, Organizations, or condition operators, or any task needing a service or execution role. Does not cover non-IAM authorization like Cognito user-pool policies or app-level RBAC.
| File | Kind | Size |
|---|---|---|
| .aws-skill-metadata | other | 18 B |
| SKILL.md | skill md | 7.2 KB |
| references/aws-iam-policy-generation.md | markdown | 39.0 KB |
| references/aws-iam-role-management.md | markdown | 6.7 KB |
| references/common-pitfalls.md | markdown | 5.8 KB |
| references/service-authorization.md | markdown | 2.7 KB |
references/common-pitfalls.md
View on GitHub# Common Pitfalls
## Assuming Direct Name Mapping
API operation names and IAM action names frequently differ. Always query the service authorization reference.
```json
{
"Action": "dynamodb:QueryItems"
}
```
Wrong — the correct action is `dynamodb:Query`.
## Missing Required Actions for an Operation
Some operations require multiple IAM actions. For example, `dynamodb:BatchExecuteStatement` requires `dynamodb:PartiQLDelete`, `dynamodb:PartiQLInsert`, `dynamodb:PartiQLSelect`, and `dynamodb:PartiQLUpdate`.
## Using Wildcard Resources Unnecessarily
```json
{
"Action": "s3:GetObject",
"Resource": "*"
}
```
Too broad. Specify bucket and object paths: `arn:aws:s3:::my-bucket/*`.
## ForAnyValue/ForAllValues on Non-Array Condition Keys
`ForAnyValue` and `ForAllValues` MUST only be used with array-typed condition keys.
**Check the type** using the service reference `ConditionKeys` array:
- **Array types** (safe for set operators): `ArrayOfString`, `ArrayOfARN`, `ArrayOfNumeric`
- Examples: `aws:TagKeys`, `dynamodb:Attributes`, `dynamodb:LeadingKeys`
- **Scalar types** (do NOT use set operators): `String`, `Bool`, `ARN`, `Numeric`
- Examples: `dynamodb:EnclosingOperation`, `dynamodb:FullTableScan`
## ForAnyValue in Deny Statements Without Null Check
`ForAnyValue` evaluates to `FALSE` when the context key does not exist. Deny statements using `ForAnyValue` will not block requests when the key is missing.
❌ **Incorrect:**
```json
{
"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:**
```json
{
"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 in Allow Statements Without Null Check
`ForAllValues` evaluates to `TRUE` when the context key does not exist. Allow statements using `ForAllValues` will grant access when the key is missing.
❌ **Incorrect:**
```json
{
"Effect": "Allow",
"Action": "s3:PutObject",
"Resource": "*",
"Condition": {
"ForAllValues:StringEquals": { "aws:TagKeys": "a" }
}
}
```
✅ **Correct — require the key to exist:**
```json
{
"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`.
## Case-Sensitive Matching on aws:TagKeys in Tag-Protection Deny Statements
Tag keys are matched with different case rules depending on where they appear in a condition:
- `aws:TagKeys` carries tag keys as **values**. `StringEquals` and `StringLike` compare values case-sensitively, so `"aws:TagKeys": "protected-tag"` does NOT match a request tag key `PROTECTED-TAG`.
- In `aws:PrincipalTag/<key>`, `aws:ResourceTag/<key>`, and `aws:RequestTag/<key>`, the tag key is part of the **condition key name**, and condition key names are case-insensitive. `aws:PrincipalTag/protected-tag` matches a principal tag named `protected-tag`, `Protected-Tag`, or `PROTECTED-TAG`.
A Deny that protects an authorization tag with a case-sensitive operator therefore does not work as expected: the principal supplies a re-cased key, the Deny does not fire, and every policy that reads the tag via `aws:PrincipalTag`/`aws:ResourceTag` still matches it.
❌ **Incorrect — bypassed by tagging with `PROTECTED-TAG` (or any other casing):**
```json
{
"Effect": "Deny",
"Action": ["iam:TagRole", "iam:UntagRole", "iam:TagUser", "iam:UntagUser"],
"Resource": "*",
"Condition": {
"ForAnyValue:StringEquals": {
"aws:TagKeys": "protected-tag"
}
}
}
```
✅ **Correct — use the case-insensitive operator:**
```json
{
"Effect": "Deny",
"Action": ["iam:TagRole", "iam:UntagRole", "iam:TagUser", "iam:UntagUser"],
"Resource": "*",
"Condition": {
"ForAnyValue:StringEqualsIgnoreCase": {
"aws:TagKeys": "protected-tag"
}
}
}
```
Rules for this pattern:
1. `StringLike` has no `IgnoreCase` variant. Do not protect tag keys with wildcard patterns — list the exact key names with `StringEqualsIgnoreCase` instead.
2. Do not add a companion `Null` Deny statement (unlike the `ForAnyValue:StringNotLike` pattern above). This Deny is meant to fire only when a protected key is present; denying when `aws:TagKeys` is absent would block every untagged request for those actions.
3. Case-sensitive matching is acceptable when the operator selects the keys to **permit** (`Allow` + `ForAllValues:StringEquals` on `aws:TagKeys`): a re-cased key is simply outside the allowlist, so do not switch an allowlist to `StringEqualsIgnoreCase`. That Allow still needs the `Null: {"aws:TagKeys": "false"}` condition from the section above — `ForAllValues` alone evaluates to true when the request carries no tag keys, which would allow untagged requests.
## Adding Conditions When They Are Not Needed
For identity policies, most policies only need Actions and Resources. Add conditions only when:
- Restricting sensitive actions (e.g., requiring MFA for `iam:DeleteUser`)
- Implementing tag-based access control (TBAC)
- Enforcing organizational requirements (encryption, VPC restrictions)
Resource policies more commonly use conditions (VPC endpoints, source IPs, secure transport).
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |