Reviewing IAM changes in Terraform and OpenTofu plans
What a plan shows about an access change, what it leaves out, which resource types change who can reach what, and a checklist for reviewing them.
A terraform plan or tofu plan tells you which resources will be created, changed or destroyed. For most infrastructure that is the question a reviewer needs answered. For IAM it is only the start. A plan that says “1 to change” can describe a one-line edit to a trust policy that opens a path to a production table, and the plan output will not say so.
This guide covers what plans do and do not show, which resource types change access, how to read them, and a checklist for review. Terraform and OpenTofu are treated alike. For this purpose the two tools produce the same kind of plan and differ in the command name, so every command below is shown for both.
Produce a plan you can review
Save the plan to a file and apply that file, so that what was reviewed is what gets applied:
terraform plan -out=tfplan
terraform show tfplan # human-readable
terraform show -json tfplan # machine-readable
tofu plan -out=tfplan
tofu show tfplan
tofu show -json tfplan
Treat the plan file and its JSON as sensitive. The readable output masks values marked sensitive, but the plan file can contain them. Keep plan artifacts out of public logs and storage with open access, and give them a short retention.
What a plan shows
- Which resources are created, updated in place, replaced or destroyed.
- The attributes that change, with old and new values.
- For
jsonencodepolicies, the changed fields inside the JSON document, in recent versions of both tools. In older output you may see the whole string replaced. - Changes outside the code that were found when state was refreshed, under “Objects have changed outside of Terraform”.
For a trust change, a readable plan looks like this (abbreviated, illustrative):
# aws_iam_role.data_maintenance will be updated in-place
~ resource "aws_iam_role" "data_maintenance" {
~ assume_role_policy = jsonencode(
~ {
~ Statement = [
~ {
~ Principal = {
~ AWS = [
+ "arn:aws:iam::111122223333:role/ci-deploy-role",
"arn:aws:iam::111122223333:role/ops-maintenance-role",
]
}
},
]
}
)
}
Plan: 0 to add, 1 to change, 0 to destroy.
That is the change from pull request #187 in the sample repository, in infra/iam/data-access.tf. The plan is accurate. It is also a summary of what changes in the file, not of what changes in access.
What a plan does not show
- Effective access. A plan shows one policy changing. It does not combine that policy with the rest: other policies on the same role, the permissions of roles that can assume it, permission boundaries or organization-level controls.
- Paths. Whether
ci-deploy-rolecan already assumedata-maintenance-roleis in a different resource, and the plan does not connect the two. - Values unknown until apply. An attribute computed during apply appears as
(known after apply). If a principal or a scope comes from another resource that is being created, you can read the plan and still not know what it will say. - Anything not in state. A policy attached by hand, or a resource managed by another team’s configuration, is not part of this plan. The refresh step can show drift on resources the configuration manages, but it says nothing about resources the configuration has never heard of.
- Use. Authorization is not activity. A plan cannot tell you whether anyone depends on an access you are about to remove.
Resource types that change access
Reviewers can learn to recognize the types that carry access. The list below is illustrative, not complete.
| Cloud | Resource types | What they control |
|---|---|---|
| AWS | aws_iam_role (assume_role_policy) |
Who can assume a role |
| AWS | aws_iam_role_policy, aws_iam_policy, aws_iam_role_policy_attachment |
What an identity can do |
| AWS | aws_iam_openid_connect_provider |
Which external issuers are trusted |
| AWS | aws_s3_bucket_policy, aws_kms_key |
Access granted on the resource itself |
| Google Cloud | google_project_iam_member, _binding, _policy |
Roles on a project, inherited by its resources |
| Google Cloud | google_folder_iam_*, google_organization_iam_* |
Roles inherited by everything below |
| Google Cloud | google_service_account_iam_* |
Who can impersonate or use a service account |
| Azure | azurerm_role_assignment |
A role for a principal at a scope, inherited below it |
| Azure | azurerm_federated_identity_credential |
Which external identities can sign in as a managed identity |
Some types are authoritative, and that changes what a plan means. A google_project_iam_binding owns every member of its role, so a plan can remove members that were added elsewhere. A google_project_iam_policy owns the whole policy. When you see one in a plan, read the destroyed and removed entries as carefully as the added ones.
Reading a plan for access
Plans can be long. Filter the JSON to the types that carry access, then read each one in full:
terraform show -json tfplan | jq '
.resource_changes[]
| select(.type | test("iam|role_assignment|federated_identity"))
| {address, actions: .change.actions}'
For OpenTofu, replace terraform with tofu. For each change, .change.before and .change.after hold the old and new attribute values, and .change.after_unknown marks the ones that are not known yet.
A review checklist
For each IAM change in a plan, ask:
- Who gains access? Name the identity. For a trust or binding change, it is the principal being added, not the resource being edited.
- What can they reach? Follow it: the target’s permissions, any role it can assume, any service account it can impersonate, and the resources those hold roles on.
- Was something already half built? Check whether the new principal already has the matching permission, as in the AWS trust policy guide, or an existing token creator grant, as in the service account guide.
- How wide is the scope? A role granted at a resource group, project or folder reaches everything below it. Ask whether a narrower scope would do the job.
- Is the change authoritative? Read removals, and check whether anything is about to be removed that was added outside Terraform.
- Are values unknown? If the principal or scope is
(known after apply), find out where it comes from. - Is it a replacement? A replaced role is a new role. Policies attached to the old one outside this configuration are not carried over.
- Do the descriptions match the change? If the title says “update data maintenance role” and the plan adds a new principal to a trust list, ask why.
- What is the CI identity? Check which role the pipeline running
applyuses, because it has to be able to change IAM. See the CI/CD guide.
Write down the answer as a path, from identity to resource. A review comment that says “this lets the deploy workflow write to CustomerRecords through data-maintenance-role” can be acted on. “IAM change, please check” cannot.
What happens after apply
A plan describes intent, not the deployed state. After apply, a change made in the console, or by another tool, can differ from your configuration. Running a plan on a schedule, or terraform plan -refresh-only or tofu plan -refresh-only, shows differences between state and the real resources. That check covers resources the configuration manages. It does not find access that the configuration never defined.
How AccessRoot surfaces it
AccessRoot reads the plan your pipeline already produces, whether from terraform plan or tofu plan, and evaluates the proposed change against the access model of the connected accounts. It reports the paths a change adds, removes or changes on the pull request, with a link to the file behind each. For #187, Access Diff reports the new write path to CustomerRecords as a finding. AccessRoot treats plans as sensitive input and does not run apply. See Terraform and OpenTofu for how plans are read and handled, and Access Drift for comparing approved and observed access after deployment.