Skip to main content
INS // Insights

Pulumi OIDC AWS for Plan and Apply Roles

Updated October 2026 · 7 min read

Pulumi OIDC AWS is Pulumi Cloud, through ESC, assuming an IAM role with a short-lived token so the stack no longer stores an AWS access key. The pain is that key in the stack config or in an ESC environment that still uses static credentials. Anyone who can open the stack, and anyone who can open the environment, can take a key that plan and apply both use. The key does not know the difference between a preview and an update. A leaked key is a standing credential for the whole account policy attached to it. The buyer wants the preview to be read-only and the apply to be a different role, and they want the key gone after both paths have worked once.

Pulumi's ESC guide for AWS registers the issuer https://api.pulumi.com/oidc and an audience of aws: plus the organization name. The role trust allows sts:AssumeRoleWithWebIdentity. Rutagon's cutover is two environments and two roles, with the subject pinned so the plan environment cannot assume the apply role. Static aws:accessKey and aws:secretKey values leave the stack only after CloudTrail shows the assume.

How Pulumi OIDC AWS separates plan and apply

One OIDC provider exists per account for that issuer. AWS will not create a second provider with the same URL. Plan and apply are two roles that trust the same provider, with different permissions and different subject conditions. The plan role can read what a preview needs. The apply role can change the resources that stack owns. Neither role is AdministratorAccess unless the stack truly administers the account, and even then the apply role is the only one that holds it, and the plan role does not.

The audience in the trust is aws:<org> for ESC. The exception Pulumi documents is the default project, where the audience is the organization name alone. A trust copied from the ESC example will fail for a legacy default-project environment, and the error looks like a generic access denied. We read the audience off a real token from the environment that will run, and we put that value in StringEquals. We do not standardize on one audience string across every project until we have seen the token.

The subject is the other condition, and the default is a trap. A wildcard subject of pulumi:environments:org:<org>:env:* lets every environment in the organization assume the role. Worse, when ESC feeds Pulumi IaC, the default subject identifier is the same literal for every environment. Plan and apply then satisfy one trust. The role cannot tell them apart. We set subjectAttributes on the login so the subject includes currentEnvironment.name, open the environment, and pin StringEquals to the subject that open printed.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "Federated": "arn:aws:iam::ACCOUNT_ID:oidc-provider/api.pulumi.com/oidc"
      },
      "Action": "sts:AssumeRoleWithWebIdentity",
      "Condition": {
        "StringEquals": {
          "api.pulumi.com/oidc:aud": "aws:ORG",
          "api.pulumi.com/oidc:sub": "SUBJECT_FROM_PULUMI_ENV_OPEN"
        }
      }
    }
  ]
}

The ESC environment uses fn::open::aws-login with the role ARN and a one-hour duration. The environment exports AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_SESSION_TOKEN from that login. Those values are temporary outputs of the assume. They are not the long-lived key this cutover deletes. The stack consumes the environment. It does not embed a key in Pulumi.<stack>.yaml.

A helper in the CLI can create the provider, a single role, and an environment in one step, and the policy it attaches can be AdministratorAccess. That is a fast way to prove the issuer works. It is a poor way to leave production. We may use it to confirm the provider URL, then we replace the role with the plan and apply pair and delete the broad role. One role for every environment is the standing credential in a different costume.

Deleting the static key from the stack

The inventory is the stack config, the ESC environments, and any CI variable that still injects an AWS key for Pulumi. Terraform Cloud dynamic credentials are the same pattern on a different issuer. A team running both tools gets two providers. Removing the Pulumi key and leaving the Terraform key is a half migration. The ledger has a row per tool.

We run a preview against the plan role and an update against the apply role in a non-production stack first. CloudTrail must show AssumeRoleWithWebIdentity for each role, with the subject we pinned. A preview that assumed the apply role means the subject pin is wrong, and we stop. After both assumes match, we remove aws:accessKey and aws:secretKey from the stack and the static login block from ESC. The next preview has to succeed with the environment alone. If it fails, the fix is the trust or the subjectAttributes. Putting the key back is a reopened row, not the remediation.

org: client
plan_env: prod-plan
apply_env: prod-apply
plan_subject_pinned: true
apply_subject_pinned: true
static_aws_keys_in_stack: 0
assume_plan_seen: true
assume_apply_seen: true

The IAM user that owned the old key is handled the same way as any other retired key. Disable, confirm the OIDC path, delete. A key that remains active because "Pulumi Cloud also uses it" is still a key. If another system uses it, that system gets its own row and its own cutover. The Pulumi row does not close while the key is active.

Session duration stays at the one hour the ESC example uses, unless a stack's apply genuinely runs longer. A longer duration is written on the environment and on the evidence row. It is not a reason to switch back to a permanent key. The role's permissions are still the bound. A six-hour session on a read-only plan role is a smaller problem than a permanent key on an admin user.

What reviewers look at after the cutover

The review item is the role, not the person who clicked up. Reviewers see the environment name, the subject, the role ARN, the policy ARN, and the last assume time. A plan role whose policy contains iam:CreateRole or ec2:TerminateInstances is wider than a preview. We flag that. An apply role that has not been assumed inside the deploy window is either unused or the stack is applying with something else. The static-key scan answers which.

Organization stacks that deploy into several accounts need a provider and a role pair in each account. The ESC environment can assume one role, and that role can assume onward, or each account can be its own environment. We pick one and record it. A cross-account hop with no external id and no source-role condition is a new standing path. The evidence row names the hop. AWS cloud infrastructure is where those account boundaries are built. Security automation is where the key inventory and the CloudTrail recheck run.

Rutagon delivers the provider, the two roles, the subject pins, and the removal of the static key. Pulumi Cloud remains the issuer. AWS remains the account. Our store is the subject each environment presented and the proof the key no longer sits on the stack.

Frequently Asked Questions

Why can the plan environment assume the apply role?

The default subject does not carry a distinct environment name for every ESC environment that feeds IaC. A wildcard, or that shared default subject, matches both. We set subjectAttributes so the subject includes the environment name, then StringEquals the exact subject pulumi env open printed for that environment.

What audience goes in the trust policy?

For ESC it is aws: followed by the Pulumi organization name. The documented exception is the default project, whose audience is the organization name with no prefix. We copy the audience from a token the real environment issued, because a mismatch returns access denied and the policy never runs.

When is the access key deleted?

After CloudTrail shows AssumeRoleWithWebIdentity for the plan role from the plan environment and for the apply role from the apply environment. The key is disabled through one successful preview first, then deleted. A preview that still used the key does not count, even if the preview succeeded.

Does one role for the whole organization meet the same bar?

A single role every environment can assume, especially one with AdministratorAccess, is the pattern the quick setup creates. The cutover we leave in place is two roles: the plan role cannot apply, and the apply role's trust names the apply environment's subject. The broad role is deleted once those assumes are in the trail.

Ask for a credential diagnostic that finds static AWS keys in Pulumi stacks and moves plan and apply onto OIDC roles. Contact Rutagon at https://rutagon.com/contact, 907-841-8407, or contact@rutagon.com.