We’re having issues setting up AWS OIDC for an ESC...
# esc
g
We’re having issues setting up AWS OIDC for an ESC env - details in 🧵
This is our trust relationship:
Copy code
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "Federated": "<pulumi oidc arn>"
      },
      "Action": "sts:AssumeRoleWithWebIdentity",
      "Condition": {
        "StringEquals": {
          "api.pulumi.com/oidc:aud": "aws:<companyname>",
          "api.pulumi.com/oidc:sub": "pulumi:environments:org:<companyname>:env:<project>/<env>"
        }
      }
    }
  ]
}
When I try to open the env, I get
Copy code
Error: could not authenticate with AWS.
		Error: 
		Error: Please ensure that your trust relationship is correct
...
InvalidIdentityToken: Incorrect token audience
the suggested subject/aud in the error message exactly match my Conditions above. the project wasn’t cloned from default or anything like that. any idea why?
For reference: x-pulumi-request-id:4c6d4ad6-a8cb-484c-8e98-7b733236b309
Filed a ticket #6752
Figured it out: we had to add the aws:<companyname> audience to the allowlist of audiences in the IDP config in IAM.
r
@gifted-balloon-26385 is there anything you would add to the docs that would've helped you resolve this?
g
The reason the section at the top of this page explaining the IDP setup didn’t help was because we set up OIDC before projects (so we only had <org> in our allowlist), so I never went back to the setup section and forgot it that allowlist existed. I think what would be most helpful is just to add to the error message when sts:assumerole fails: “Please ensure that your trust relationship is correct *and that your AWS Identity Provider for Pulumi has the aws:<org> audience configured*”
I was also staring at this section the entire time, so a callout in there as a reminder would probably have pre-empted it https://www.pulumi.com/docs/pulumi-cloud/access-management/oidc/provider/aws/#pulumi-esc
r
That's really helpful feedback thank you!