DevTools Logo

AWS IAM Least-Privilege Generator

AWS IAM Least-Privilege Generator

Build a scoped IAM policy from a curated service and action catalog. Nothing is sent anywhere.

Runs in your browser
Try an example

Service actions

One resource ARN per line
Amazon S3
Amazon DynamoDB
Amazon SQS
Amazon SNS
AWS Lambda
Amazon CloudWatch Logs
Amazon EC2
AWS STS

Generated IAM policy

16 lines · 260 chars
Resource ARNs still contain ${placeholders} such as ${bucket}. Replace them with real values before using the policy: IAM treats them as policy variables that never match.
This is a generator, not a verifier: it does not prove the policy is least privilege. Review it with IAM Access Analyzer or the policy simulator before attaching it.

Structure check passed: valid IAM policy JSON. This does not verify least privilege.

About

Select common AWS service actions, provide resource ARN templates, and add optional SourceIp or S3 prefix conditions. Everything runs locally in your browser.

Examples

S3 read-only policy

Input
buildAwsIamPolicy({ selections: [{ service: "s3", actions: ["s3:GetObject", "s3:ListBucket"] }], resources: { s3: ["arn:aws:s3:::reports", "arn:aws:s3:::reports/*"] } })
Output
Action: ["s3:GetObject", "s3:ListBucket"], Resource: both report ARNs

Read-only actions serialize sorted with explicit bucket ARNs and validate cleanly as JSON.

Unknown action filtered with placeholder

Input
buildAwsIamPolicy({ selections: [{ service: "sqs", actions: ["sqs:SendMessage", "sqs:DeleteQueue"] }] })
Output
Action: ["sqs:SendMessage"], Resource: ["arn:aws:sqs:${region}:${account}:${queue}"]

DeleteQueue is not in the catalog so it is dropped, and the SQS template placeholder fills the Resource.

About this tool

AWS IAM Least-Privilege Generator builds a least-privilege policy with buildAwsIamPolicy(config): selections are intersected against the embedded AWS_IAM_CATALOG (s3, dynamodb, sqs, sns, lambda, logs, ec2, sts), unknown actions like sqs:DeleteQueue are silently dropped, and the surviving Action list sorts deterministically before serialization.

Resources resolve per selected service: explicit resources win (trimmed, blanks dropped), otherwise the catalog's resourceTemplates supply placeholders such as arn:aws:s3:::${bucket} or arn:aws:sqs:${region}:${account}:${queue}, deduplicated across services and defaulting to ["*"] when nothing resolves. An optional conditions map attaches as a key-sorted Condition block.

The output is canonical JSON ({Version: 2012-10-17, Statement: [{Effect, Action, Resource, Condition?}]}) that validateAwsIamPolicy can re-check for version, Effect, Action, and Resource presence. All catalog data is local, so account IDs and queue names never leave the browser.

How to use this tool

  1. Select services and catalog actions

    Tick only the actions each workload needs — anything outside the embedded catalog is filtered out automatically.

  2. Fill in resource ARNs or keep placeholders

    Provide concrete ARNs per service, or leave them blank to emit template placeholders like ${bucket} for later substitution.

  3. Add conditions and effect

    Attach an optional Condition map (e.g. StringEquals on aws:PrincipalTag/team) and pick Allow or Deny for the Effect.

  4. Copy and validate the JSON

    Paste the sorted policy into IAM and run it through validateAwsIamPolicy or the IAM policy simulator before attaching.

Use cases

Scoping application roles

Generate minimal S3/DynamoDB/SQS statements for a service role instead of hand-writing wildcards.

Drafting reviewable policies

Produce sorted, deterministic JSON that diffs cleanly in pull-request review.

Templating multi-account policies

Emit ${region}/${account} placeholders for pipelines that substitute per environment.

Common mistakes

Mistake:Requesting an action and assuming it appears verbatim.

Fix:Only catalog-listed actions survive — sqs:DeleteQueue is dropped silently, so check getAwsIamActions(service) for the supported set.

Mistake:Expecting an empty Resource when no ARNs are given.

Fix:Missing resources fall back to catalog templates (or "*"), never to an empty list — substitute the placeholders before deploying.

Mistake:Hand-editing the JSON and breaking its shape.

Fix:Keep Version 2012-10-17 with Statement Effect/Action/Resource, or validateAwsIamPolicy will flag the missing fields.

Frequently asked questions

What does this tool do?

It builds a least-privilege IAM policy with buildAwsIamPolicy: selections intersect the embedded catalog (s3, dynamodb, sqs, sns, lambda, logs, ec2, sts), Actions sort deterministically, Resources resolve to explicit ARNs or template placeholders, and an optional Condition block attaches sorted.

What happens to actions outside the catalog?

They are silently dropped — sqs:DeleteQueue is not a catalog action, so requesting it alongside sqs:SendMessage yields only SendMessage. Check getAwsIamActions(service) for the supported set.

Is my account data uploaded or stored?

No. The catalog is embedded and policy assembly runs locally — account IDs, ARNs, and conditions never leave your browser.

How are resources and conditions filled in?

Explicit per-service ARNs win (trimmed, blanks dropped); otherwise catalog templates like arn:aws:s3:::${bucket} apply, defaulting to ["*"] when nothing resolves. Conditions serialize as a key-sorted Condition block, and validateAwsIamPolicy re-checks Version, Effect, Action, and Resource.

References & standards