IAM Policy Lint

IAM Policy Lint

Open a saved Terraform plan JSON to see which AWS IAM policy statements it adds and removes, then copy a pull-request note that keeps the counts and leaves out every name and value.

One file · .json · up to 10 MiB · stays in this tab

Loading the reviewer…

Open one saved Terraform plan to see its IAM policy changes.

You get the statements added and removed in each policy, shown only on this page, and a pull-request note that keeps counts and leaves out every name and value.

  • Managed policies: aws_iam_policy
  • Inline role policies: aws_iam_role_policy
  • Role trust policies: aws_iam_role

What it does

Terraform shows an IAM policy change as one long JSON string, so a reordered statement looks the same as a new permission. This page reads the saved plan in your browser, compares each managed policy, inline role policy and role trust policy statement by statement, and lists what was added and removed. It then writes a pull-request note from fixed words and counts only, so you can say what kind of IAM change a PR makes without pasting role names, account IDs or actions into a review thread.

Worked example: a deploy role gains iam:PassRole

{
  "Effect": "Allow",
  "Action": "s3:PutObject",
  "Resource": "arn:aws:s3:::contoso-deploy-artifacts/*"
}
{
  "Effect": "Allow",
  "Action": "s3:PutObject",
  "Resource": "arn:aws:s3:::contoso-deploy-artifacts/*",
  "Condition": {
    "StringEquals": {
      "s3:x-amz-acl": "bucket-owner-full-control"
    }
  }
}
{
  "Effect": "Allow",
  "Action": "iam:PassRole",
  "Resource": "arn:aws:iam::000000000000:role/contoso-deploy-worker"
}
The note it writes
PR noteIdentifiers omitted
### IAM policy changes

- Managed permissions: 1 statement added, 0 removed, 1 document with top-level field changes.
- Inline permissions: 2 statements added, 1 removed, 0 documents with top-level field changes.
- Role trust: 1 statement added, 1 removed, 0 documents with top-level field changes.
- Unreviewed IAM resource changes: 1.

The role name, bucket and actions stay on your screen; only the counts go into the pull request.

How to use it

  1. Save the plan as JSON: terraform plan -out=plan.tfplan, then terraform show -json plan.tfplan > plan.json.
  2. Drop plan.json on the page or choose it.
  3. Read the added and removed statements, then press Copy PR note and paste it into the pull request.

What it does not do

Questions

Why does an edited statement show as one removed and one added?

Statements are compared whole. Any change inside one, even a single action, makes it a different statement. The old one appears under Statements removed and the new one under Statements added.

Does reordering statements count as a change?

No. Statements are matched regardless of order, and key order inside them is ignored. Order inside lists, such as Action, still counts.

What exactly goes into the PR note?

A heading and four lines of counts, built from fixed words. No resource address, role or policy name, ARN, statement ID, action, principal, condition or file name.

Is my plan sent anywhere?

No. The file is read and compared in this tab. Once the page and reviewer have loaded, it works with the network off. Closing the tab clears the review.

See it work

Three changed policies and one review gap are counted in the PR note.
Three changed policies and one review gap are counted in the PR note.
The note you paste into the pull request: counts only, ready to copy.
The note you paste into the pull request: counts only, ready to copy.
Changes it cannot read are named, not guessed: unknown until apply, unsupported types.
Changes it cannot read are named, not guessed: unknown until apply, unsupported types.

More pictures, and how IAM Policy Lint works