-
Notifications
You must be signed in to change notification settings - Fork 486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Could not assume role with OIDC: Not authorized to perform sts:AssumeRoleWithWebIdentity - Why? #1238
Comments
removed: environment: ${{ github.event.inputs.environment }} to fix this issue aws-actions/configure-aws-credentials#1238
@maximillianus I recently implemented this. When you add an environment to a GitHub Actions job, it indeed changes the format of the sub claim in the OIDC token. This change is not immediately obvious and can cause confusion when setting up IAM roles for OIDC authentication. When an environment is specified in a job, the sub claim in the OIDC token changes from:
|
@maximillianus Using both formats If you need more precise control, you can include conditions for both formats:
Adjusting your IAM role configurations accordingly |
These are the Terraform modules I used for AWS: |
Thanks @jsandov . Those exactly what I did too after further research, but discovering this is not exactly straightforward. I wish there is some documentation from the aws-action Github team here. Again, while * wildcard works fine (and convenient), I prefer least privileged style with more control. Thanks for the answer. |
@maximillianus I linked the TF modules above. You will need to handle this at the infrastructure as code level. More precisely at the at the trust policy level which goes into the IAM role. This is how I am handling the different repos and environments that can be plugged in. Hopefully this helps! Here is a trust policy I created for least privileged access to repo and environment.
|
Describe the issue
Referring to this error in assuming role using OIDC (issues 1137).
I wonder what's the actual issue? This issue came up when I use
environment
in my workflow.I resolve this by making my
sub
to be more generic and it works.Was:
Now:
But I dont' understand how adding environment changes the repo's URL syntax. Can anybody show me how so I can make more specific & least privileged URL syntax. I am expecting something like this
The text was updated successfully, but these errors were encountered: