PermCheck

PermCheck reads a Terraform plan and checks that your deploy role's IAM policy allows the API calls the apply will make. It runs before terraform apply, so a missing permission shows up in the pull request, before a deploy fails on it.

An example finding

The plan below creates an SQS queue with tags. The deploy policy grants sqs:CreateQueue and the other queue actions, but leaves out sqs:TagQueue. The AWS provider calls TagQueue when a queue has tags, so the apply would stop with AccessDenied.

$ terraform show -json plan.tfplan | terraform-permcheck validate \
    --policy-file deploy_policy.json --cloud aws
Missing IAM permissions (1):
  sqs:TagQueue [required]
    → aws_sqs_queue.orders (create)

1 resource change checked, 1 distinct missing permission found.
$ echo $?
1

Exit code 1 fails the CI step. With --format github-annotations, each finding appears as a warning annotation on the pull request, next to the resource block when the run knows its file and line.

Steps of a check

Read the plan

Each resource change in terraform show -json: create, update, replace and delete.

List the API calls

The IAM actions each resource type needs, parsed from the AWS provider source, with CloudFormation schemas for the rest.

Compare with the policy

Actions, resource ARNs and conditions in the deploy role's policy document.

Report the gaps

Text, GitHub annotations or JSON. Exit code 1 when a permission is missing.

Some permissions depend on what the plan sets. A tags block adds a tagging call, and a change to permissions_boundary adds a boundary call. PermCheck reads the planned values and asks for those permissions only when the apply makes the call.

Static HCL mode reads the .tf files directly. It runs without a plan or cloud credentials, so pull requests from forks can run the check too. AWS is the supported cloud today. GCP and Azure are not planned for 1.0, and contributions are welcome: the guide to adding a cloud provider explains how.

Install and run

GitHub Action

Listed on the Marketplace as Terraform IAM permission check. Pin it to a release tag.

- name: Check IAM permissions
  uses: elecnix/terraform-permcheck@v0.11.2
  with:
    plan-file: plan.json
    policy-file: deploy_policy.json
    terraform-root: .

Homebrew

Installs the release binary from the project tap.

brew install elecnix/tap/terraform-permcheck

Go

Builds from source with Go 1.26 or later. Binaries for Linux, macOS and Windows are on the releases page.

go install github.com/elecnix/terraform-permcheck@latest