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]: token/owner are ignored in provider, only env vars take into affect #2242

Open
1 task done
xaurx opened this issue Apr 25, 2024 · 3 comments
Open
1 task done
Labels
Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented

Comments

@xaurx
Copy link

xaurx commented Apr 25, 2024

Expected Behavior

I initialize github provider v6.2.1 (latest at the moment) as following:

provider "github" {
  owner = "myorg"
  token = "ghp_XXX"
}

and it doesn't work, yet when I supply the same owner/token in env vars GITHUB_OWNER/GITHUB_TOKEN - it works.

I tried to debug using TF_LOG_PROVIDER=info, the only interesting messages:

2024-04-25T08:37:43.668-0400 [INFO]  provider.terraform-provider-github_v6.2.1: 2024/04/25 08:37:43 [INFO] Selecting owner  from GITHUB_OWNER environment variable: timestamp=2024-04-25T08:37:43.668-0400

and soon:

2024-04-25T08:37:45.302-0400 [INFO]  provider.terraform-provider-github_v6.2.1: 2024/04/25 08:37:45 [DEBUG] Rate limit 0 reached, sleeping for 59m59.697202s (until 2024-04-25 09:37:45.000001 -0400 EDT m=+3601.3945569
18) before retrying: timestamp=2024-04-25T08:37:45.302-0400

this seems related to the fact that no token provided.

since i want to keep token encrypted in TF files I need a way to pass it to provider not using env vars. please advise.

Actual Behavior

token/owner specified directly in provider are not used.
(I verified that I don't have env vars set to any values at all)

Terraform Version

Terraform v1.5.7
on darwin_arm64

  • provider registry.terraform.io/hashicorp/github v6.2.1
  • provider registry.terraform.io/hashicorp/google v5.26.0
  • provider registry.terraform.io/integrations/github v6.2.1

Affected Resource(s)

all

Terraform Configuration Files

provider "github" {
  owner = "myorg"
  token = "ghp_XXX"
}

Steps to Reproduce

just terraform apply:

  • with token/owner specified in provider -- doesn't work
  • with token/owner specified in env vars -- works fine

Debug Output

No response

Panic Output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@xaurx xaurx added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels Apr 25, 2024
@wyatterp365

This comment was marked as spam.

@xaurx
Copy link
Author

xaurx commented Apr 25, 2024

@wyatterp365 seems you forgot/lost comment you wanted to type.

@kfcampbell kfcampbell added Status: Up for grabs Issues that are ready to be worked on by anyone and removed Status: Triage This is being looked at and prioritized labels Apr 25, 2024
@dcfsc
Copy link
Contributor

dcfsc commented May 15, 2024

I see the same behavior with the 5.45.0 provider. I was setting the GITHUB_TOKEN env var, AND an env var github_pat_token that was used to set the token into the provider block via TF_VAR_github_pat_token

provider "github" {
  owner = "XXXXXX"
  read_delay_ms = 500
  token = var.github_pat_token
}

What's weird is this worked with the same setup last week. Others in my team are currently able to use it. I spent 2 days figuring out that I need to comment out the token value:

provider "github" {
  owner = "XXXXX"
  read_delay_ms = 500
#   token = var.github_pat_token
}

with ONLY the GITHUB_TOKEN env var set, it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented
Projects
None yet
Development

No branches or pull requests

4 participants