Skip to content
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

[Bug]: Validation for assume_role_with_web_identity does not permit usage of documented environment variable AWS_WEB_IDENTITY_TOKEN_FILE #37401

Open
derekheld opened this issue May 9, 2024 · 1 comment · May be fixed by #37621
Labels
authentication Pertains to authentication; to the provider itself of otherwise. bug Addresses a defect in current functionality. provider Pertains to the provider itself, rather than any interaction with AWS.

Comments

@derekheld
Copy link

Terraform Core Version

1.8.3

AWS Provider Version

5.48.0

Affected Resource(s)

Provider configuration

Expected Behavior

Provider is able to use the environment variable AWS_WEB_IDENTITY_TOKEN_FILE to obtain the path to a file containing a JWT token.

Actual Behavior

The provider does not use the environment variable as errors out due to a validation failure.

Relevant Error/Panic Output Snippet

│ Error: Invalid combination of arguments
│ 
│   with provider["registry.terraform.io/hashicorp/aws"],
│   on provider.tf line 38, in provider "aws":
│   38:   assume_role_with_web_identity {
│ 
│ "assume_role_with_web_identity.0.web_identity_token_file": one of
│ `assume_role_with_web_identity.0.web_identity_token,assume_role_with_web_identity.0.web_identity_token_file`
│ must be specified
╵

Terraform Configuration Files

Example affected configuration:

provider "aws" {
  assume_role_with_web_identity {
    role_arn                = "arn:aws:iam::123456789012:role/ROLE_NAME"
    session_name            = "SESSION_NAME"
  }
}

Steps to Reproduce

  1. Create a role in AWS with a trust policy allowing a web identity to assume the role
  2. Obtain an identity token for the web identity permitted by the trust policy and store it in a file
  3. Set the environment variable AWS_WEB_IDENTITY_TOKEN_FILE with the path to the file
  4. Configure the aws provider to with the assume_role_with_web_identity block and provide the ARN for the role created earlier as role_arn inside that block
  5. Attempt a terraform operation (such as a plan) that would authenticate to AWS

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

Per: https://registry.terraform.io/providers/hashicorp/aws/latest/docs#assume-role-with-web-identity-configuration-reference
The environment variable AWS_WEB_IDENTITY_TOKEN_FILE can be set to provide the path to a file containing the identity token.

The validation code:


requires that EITHER web_identity_token or web_identity_token_file to be set as part of the provider configuration.

Would you like to implement a fix?

None

@derekheld derekheld added the bug Addresses a defect in current functionality. label May 9, 2024
Copy link

github-actions bot commented May 9, 2024

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label May 9, 2024
@justinretzolk justinretzolk added provider Pertains to the provider itself, rather than any interaction with AWS. authentication Pertains to authentication; to the provider itself of otherwise. and removed needs-triage Waiting for first response or review from a maintainer. labels May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
authentication Pertains to authentication; to the provider itself of otherwise. bug Addresses a defect in current functionality. provider Pertains to the provider itself, rather than any interaction with AWS.
Projects
None yet
2 participants