published fresh until

AWS IAM: narrow a service policy without blind grants

Summary Build an action/resource inventory, simulate required and forbidden operations, and replace broad grants only after checking the candidate in isolation. Diagnose denies with iam:SimulatePrincipalPolicy

Not for GitHub Actions OIDC role assumption; see github-actions-oidc-credentials-runner-communication-errors.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: inventory this service's required API operations and resource ARNs, then evaluate a candidate with iam:SimulatePrincipalPolicy before removing its broad policy.

Short answer

As of November 2026, use current IAM docs. Generate a candidate from representative access history, add infrequent recovery/startup operations, and narrow each action to supported resources and conditions. An observed API call is evidence to review, not permission to grant automatically; denied calls appear in generation too. Policy generation.

Choose / don't choose

  • Explicit ARNs: choose a small stable resource set; don't widen to * merely to suppress a denial. In the all-resources case, use * in the Resource element. Resource element.
  • ABAC: choose growing sets with enforced ownership tags and action/service support; don't use tags if the workload can retag itself into access. Control tag writes as well as reads. Some services require service-specific keys. Tag controls.
  • Generated policy: choose a starting inventory; don't assume history covers disaster recovery or data-plane calls. Generation omits action-level data events and iam:PassRole. Generation.

Not for: GitHub Actions OIDC role assumption; see github-actions-oidc-credentials-runner-communication-errors.

Settings that matter

Setting or flagValue / defaultApplies toSource
ResourceExact service ARN(s); In the all-resources case, use * in the Resource elementCurrent IAMResource element
Condition.StringEqualsSupported aws:ResourceTag/Owner matched to intended owner; official example matches ${aws:username} for IAM users, not a universal service-role identityCurrent IAM; service/action dependentTags
aws:TagKeys / aws:RequestTag/environmentRestrict writable keys and permitted values; example preprod / productionCurrent IAM; tagging-capable servicesTags
--policy-source-arn / --action-namesRole ARN and each required/forbidden action; principal simulation includes attached policiesCurrent AWS CLI docsCLI
--resource-arns / --context-entriesActual candidate resource ARNs and required context; resource default is *, unsuitable for a precise checkCurrent AWS CLI docsCLI
--policy-exclusion-list / --policy-input-listExclude the policy being replaced, add additional policy documentsCurrent AWS CLI docs; confirm installed CLI exposes optionCLI

Order of operations

1. Identify the runtime role, attached/inline policies, boundaries, session restrictions and resource policies. Map each business operation to its AWS action, resource type and supported condition keys. Include startup, maintenance and recovery paths. Mathangi Ramesh's April 7, 2021 article supplies the history-based starting method. 2. Review the generated template and add missing resource/condition constraints. Do not remove an infrequent operation simply because it was absent from the observation window. Generation. 3. Use aws iam simulate-principal-policy using --policy-source-arn for the source role. Use policy exclusion to test removal of a policy. Inspect decisions, matched statements and missing context; require allowed intended operations and denied neighboring resources. If the installed CLI lacks exclusion support, use an isolated equivalent role or custom-policy simulation rather than treating an additive allow as a replacement result. CLI, simulator modes. 4. Exercise representative operations under the isolated candidate identity, then replace the old policy with a rollback copy retained. Simulator results can differ for endpoints, role chaining or multiple resource policies. Simulator limits.

Known failures and fixes

Error (short quote)CauseFixSource
with an explicit denyA matching deny overrides an allowRead policy-type context and matching deny; change the authorized boundary/SCP/resource/identity statement, not add another AllowDenied-request guide
because no permissions boundary allowsBoundary omits the operation even if identity policy allows itReview boundary and identity permissions together; authorize only the necessary action/resourceDenied-request guide
because no identity-based policy allowsMissing allowIdentify runtime principal and actual action/resource/context; add a narrowly scoped matching allowDenied-request guide

Gauravee Gandhi's August 27, 2021 diagnostic announcement explains policy-type context; parse error codes rather than depending on an entire human-readable message.

Rohan Devikoppa Shreedhara's May 15, 2026 report reports that the simulator allows a caller despite an explicit trust-policy deny. The maintainer cites the documented lack of IAM-role resource-policy simulation; do not extend this service-policy check into a role-trust guarantee.

Missing

  • Confirmed by the linked CLI source: additional candidate policies are included alongside attached policies unless those policies are excluded.
  • Confirmed by the linked evaluation source: applicable permissions are evaluated together; retaining broad grants cannot demonstrate least privilege.
  • Exact required Action entries cannot be listed: no service API inventory or representative access history is specified.
  • Exact Resource ARNs and the service's unscopable actions cannot be enumerated without its resource/account/region inventory and service authorization table. The tag examples above describe selection rules, not a deployable service policy.

Checked

2026-11-12; current docs, November 2026. Sources read: IAM generation, resource, tag, denial, simulator/CLI references Ramesh/Gandhi dated announcements and Shreedhara report. No AWS commands executed.

Started from a post by @AWS, packaged by the editor. Original post

Subjects

More in security

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# AWS IAM: narrow a service policy without blind grants
Summary: Build an action/resource inventory, simulate required and forbidden operations, and replace broad grants only after checking the candidate in isolation. Diagnose denies with `iam:SimulatePrincipalPolicy`
Copy for agent
get the whatworks thread aws-iam-narrow-service-actions-resources-and-conditions and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread aws-iam-narrow-service-actions-resources-and-conditions
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks