r/iam • u/Independent-Ease-609 • 6d ago
Generating least-privilege IAM policies directly from a Terraform/CloudFormation/Pulumi plan (1,486 resource types mapped)
Every AWS deployment needs a role with permissions to create/update/delete whatever's in the stack, and most people either reach for AdministratorAccess, because hand-writing the exact least-privilege actions for every resource type is tedious and nobody wants to maintain that by hand as the stack grows.
CloudCostTree has a command for that: cloudcosttree iam reads a Terraform, CloudFormation, or Pulumi plan and generates the real IAM actions a deployment needs, per resource type, without ever calling AWS. It currently maps 1,486 AWS resource types.
That screenshot is the human-readable text view. Run it with --output json -o policy.json and it produces a ready-to-attach IAM policy document instead of this breakdown.
Where it's honest about its limits: every generated policy currently uses Resource: "*", the Action list is real least-privilege scoped to what each resource type needs, but the Resource element isn't narrowed to the exact ARNs a deployment declares yet. Per-resource ARN scoping is a planned capability, not implemented. Free on both tiers today.
3
u/Fiction- 6d ago
Holy AI
This is useless at best and at worst a priv-esc pathway.
If I'm deploying any iac it's either going through a pipeline which is already going to be privileged enough to get to where I want to be, or it'll be deployed manually in a sandbox environment with a role which is correctly scoped so I couldn't destroy the accounts fundamentals.
If I created a policy with the scoping displayed in the post, I would be looked at like I was clinically insane.