Closed eleni-salamani closed 1 year ago
I'm experiencing the same issue. It looks like the org information is not being pulled from the provider's configuration, but from the token. My config looks like:
# Personal access token set by `GITHUB_TOKEN` env var
provider "github" {
organization = "my-org"
}
data "github_team" "owner" {
slug = "my-team"
}
This should hit the endpoint:
https://api.github.com/orgs/my-org/teams/my-team
But it is instead hitting:
https://api.github.com/orgs/my-user/teams/my-team
With my-user
being the owner of the token set in the GITHUB_TOKEN
env var
Yup, same here. It's ignoring everything in the provider block. I was trying to pass creds in via variables.
provider "github" {
organization = "..."
token = var.github_token
}
It always returns
Error: This resource can only be used in the context of an organization, "" is a user.
Or I get rate limited because it's not authenticating.
Workaround: Use environment vars for both.
This is much broader than the data source, the provider is not inferring the organization from the provider in any circumstance for me. You may want to rename your bug.
It's a regression since 2.9. I can't say when – I'm only finally able to upgrade now that github_branch_protection_v3 exists.
Same here. After using the workaround by @jspiro and using environment vars for both everything works fine.
FYI I'm hitting a similar issue using resource "github_team" -
Error: DELETE https://{internal_api_url}/orgs/{org}/teams/{team}/memberships/{owner}: 404 Not Found []
It looks like it creates the team with myself as the maintainer and then attempts to delete me before adding the ldap_dn attribute (I'm assuming). Setting create_default_maintainer = false
doesn't solve anything.
I'll try to open another issue on this when I have more time.
@eleni-salamani, @jspiro, @aliculPix4D, I believe that this is the same issue as #696 and #697.
As the output of terraform -v
shows, hashicorp/github
and integrations/github
are both enabled in this Terraform configuration. This means that the provider "github"
block is sent to one of the providers but not the other, which means that the other provider is working in anonymous mode with no token, no owner, and no organization.
According to the debug output in the gist @eleni-salamani, it looks like integrations/github
gets the correct configuration, but hashicorp/github
is the plugin attempting to fetch detail of the b2b
team.
If you genuinely need to use both providers, then you need to configure both providers using local names. However, it's also possible that your Terraform configuration is accidentally referring to hashicorp/google
: if you use any module that attempts to use the GitHub provider, but does not declare a required_providers
section specifying integrations/github
, then it will implicitly refer to hashicorp/google
.
All modules that you want to use integrations/github
must contain
terraform {
required_providers {
github = {
source = "integrations/github"
version = ">= 4.X.Y" // or whatever version range you wish
}
}
}
@tibbes Many thanks for the reply. For the time being we have switched to using purely the hashicorp/github
provider, which works for us.
I was excited to move to integrations/github
when I saw this message:
╷
│ Warning: Additional provider information from registry
│
│ The remote registry returned warnings for registry.terraform.io/hashicorp/github:
│ - For users on Terraform 0.13 or greater, this provider has moved to integrations/github. Please update your
│ source in required_providers.
╵
And as soon as I replaced my provider using:
terraform state replace-provider registry.terraform.io/hashicorp/github registry.terraform.io/integrations/github
all github stuff broke. Tried a few things, but didn't fix it.
So, just removing the source in required_providers fixed the problem for me. Serves me right to be jumping to the new stuff immediately.
Can confirm the same experience. integrations/github is absolutely shattered by the above.
I was excited to move to
integrations/github
when I saw this message:╷ │ Warning: Additional provider information from registry │ │ The remote registry returned warnings for registry.terraform.io/hashicorp/github: │ - For users on Terraform 0.13 or greater, this provider has moved to integrations/github. Please update your │ source in required_providers. ╵
And as soon as I replaced my provider using:
terraform state replace-provider registry.terraform.io/hashicorp/github registry.terraform.io/integrations/github
all github stuff broke. Tried a few things, but didn't fix it.
So, just removing the source in required_providers fixed the problem for me. Serves me right to be jumping to the new stuff immediately. I do not have the hashicorp provider specified anywhere in the code but it still attempts to use it and keeps failing
I confirm having the same problem as above, and switching to hashicorp/github
fixes it
For me it worked to set the org name as GITHUB_OWNER
variable 👍🏼
Doesn't work here as of the latest. Still the same problem using GITHUB_OWNER
I've been playing around with this a little bit and I don't think this is fundamentally broken. I've created the following pared-down template to reproduce this issue.
First, I've created a team in my org called "some-team":
Next, I've run the following HCL:
terraform {
required_providers {
github = {
source = "integrations/github"
}
}
}
provider "github" {
owner = "kfcampbell-terraform-provider"
token = "ghp_personal_token_redacted"
}
data "github_team" "some_team" {
slug = "some-team"
}
This is able to successfully find my team, as evidenced by the following snippet of output:
2021-11-18T10:47:34.447-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: ---[ REQUEST ]---------------------------------------
2021-11-18T10:47:34.447-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: GET /orgs/kfcampbell-terraform-provider/teams/some-team HTTP/1.1
2021-11-18T10:47:34.447-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: Host: api.github.com
2021-11-18T10:47:34.447-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: User-Agent: go-github
2021-11-18T10:47:34.447-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: Accept: application/vnd.github.v3+json
2021-11-18T10:47:34.447-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: Accept-Encoding: gzip
2021-11-18T10:47:34.447-0800 [DEBUG] provider.terraform-provider-github_v4.18.0:
2021-11-18T10:47:34.447-0800 [DEBUG] provider.terraform-provider-github_v4.18.0:
2021-11-18T10:47:34.447-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: -----------------------------------------------------
2021-11-18T10:47:34.447-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: 2021/11/18 10:47:34 [TRACE] Acquiring lock for GitHub API request (%!q(<nil>))
2021-11-18T10:47:34.788-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: 2021/11/18 10:47:34 [TRACE] Releasing lock for GitHub API request (%!q(<nil>))
2021-11-18T10:47:34.788-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: 2021/11/18 10:47:34 [DEBUG] Github API Response Details:
2021-11-18T10:47:34.788-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: ---[ RESPONSE ]--------------------------------------
2021-11-18T10:47:34.788-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: HTTP/2.0 200 OK
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0:
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: {
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "name": "some-team",
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "id": 5373491,
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "node_id": "redacted",
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "slug": "some-team",
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "description": "Some cool team",
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "privacy": "closed",
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "url": "https://api.github.com/organizations/80981761/team/5373491",
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "html_url": "https://github.com/orgs/kfcampbell-terraform-provider/teams/some-team",
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "members_url": "https://api.github.com/organizations/80981761/team/5373491/members{/member}",
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "repositories_url": "https://api.github.com/organizations/80981761/team/5373491/repos",
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "permission": "pull",
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "created_at": "2021-11-15T06:19:38Z",
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "updated_at": "2021-11-15T06:19:38Z",
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "members_count": 0,
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "repos_count": 0,
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "organization": {
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "login": "kfcampbell-terraform-provider",
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "id": 80981761,
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "node_id": "redacted",
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "url": "https://api.github.com/orgs/kfcampbell-terraform-provider",
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "repos_url": "https://api.github.com/orgs/kfcampbell-terraform-provider/repos",
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "events_url": "https://api.github.com/orgs/kfcampbell-terraform-provider/events",
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "hooks_url": "https://api.github.com/orgs/kfcampbell-terraform-provider/hooks",
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "issues_url": "https://api.github.com/orgs/kfcampbell-terraform-provider/issues",
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "members_url": "https://api.github.com/orgs/kfcampbell-terraform-provider/members{/member}",
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "public_members_url": "https://api.github.com/orgs/kfcampbell-terraform-provider/public_members{/member}",
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "avatar_url": "https://avatars.githubusercontent.com/u/80981761?v=4",
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "description": "@kfcampbell uses this organization for testing work on the GitHub terraform provider",
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "name": "kfcampbell-terraform-provider",
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "company": null,
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "blog": null,
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "location": null,
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "email": null,
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "twitter_username": null,
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "is_verified": false,
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "has_organization_projects": true,
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "has_repository_projects": true,
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "public_repos": 43,
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "public_gists": 0,
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "followers": 0,
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "following": 0,
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "html_url": "https://github.com/kfcampbell-terraform-provider",
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "created_at": "2021-03-19T18:43:16Z",
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "updated_at": "2021-08-18T20:25:29Z",
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "type": "Organization"
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: },
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "parent": null
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: }
2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: -----------------------------------------------------
I've also successfully done this by setting the GITHUB_OWNER and GITHUB_TOKEN environment variables instead of doing so in the provider block.
Can anybody experiencing this issue please try the above configuration and let me know if it works for you?
@kfcampbell, I experienced all the symptoms described here but with a different resource (github_branch_protection_v3
), and adding GITHUB_OWNER
to the environment fixed it (I was already setting GITHUB_TOKEN
).
Unfortunately, in my case, this meant I had to do a major refactoring because I was using two separate GitHub providers to manager repos in two different organisations, so I had to break up the workspace into two (one for each org) -- even though I really would've preferred to keep everything in one workspace.
I've been playing around with this a little bit and I don't think this is fundamentally broken. I've created the following pared-down template to reproduce this issue.
First, I've created a team in my org called "some-team":
Next, I've run the following HCL:
terraform { required_providers { github = { source = "integrations/github" } } } provider "github" { owner = "kfcampbell-terraform-provider" token = "ghp_personal_token_redacted" } data "github_team" "some_team" { slug = "some-team" }
This is able to successfully find my team, as evidenced by the following snippet of output:
2021-11-18T10:47:34.447-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: ---[ REQUEST ]--------------------------------------- 2021-11-18T10:47:34.447-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: GET /orgs/kfcampbell-terraform-provider/teams/some-team HTTP/1.1 2021-11-18T10:47:34.447-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: Host: api.github.com 2021-11-18T10:47:34.447-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: User-Agent: go-github 2021-11-18T10:47:34.447-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: Accept: application/vnd.github.v3+json 2021-11-18T10:47:34.447-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: Accept-Encoding: gzip 2021-11-18T10:47:34.447-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: 2021-11-18T10:47:34.447-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: 2021-11-18T10:47:34.447-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: ----------------------------------------------------- 2021-11-18T10:47:34.447-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: 2021/11/18 10:47:34 [TRACE] Acquiring lock for GitHub API request (%!q(<nil>)) 2021-11-18T10:47:34.788-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: 2021/11/18 10:47:34 [TRACE] Releasing lock for GitHub API request (%!q(<nil>)) 2021-11-18T10:47:34.788-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: 2021/11/18 10:47:34 [DEBUG] Github API Response Details: 2021-11-18T10:47:34.788-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: ---[ RESPONSE ]-------------------------------------- 2021-11-18T10:47:34.788-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: HTTP/2.0 200 OK 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: { 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "name": "some-team", 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "id": 5373491, 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "node_id": "redacted", 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "slug": "some-team", 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "description": "Some cool team", 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "privacy": "closed", 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "url": "https://api.github.com/organizations/80981761/team/5373491", 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "html_url": "https://github.com/orgs/kfcampbell-terraform-provider/teams/some-team", 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "members_url": "https://api.github.com/organizations/80981761/team/5373491/members{/member}", 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "repositories_url": "https://api.github.com/organizations/80981761/team/5373491/repos", 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "permission": "pull", 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "created_at": "2021-11-15T06:19:38Z", 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "updated_at": "2021-11-15T06:19:38Z", 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "members_count": 0, 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "repos_count": 0, 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "organization": { 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "login": "kfcampbell-terraform-provider", 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "id": 80981761, 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "node_id": "redacted", 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "url": "https://api.github.com/orgs/kfcampbell-terraform-provider", 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "repos_url": "https://api.github.com/orgs/kfcampbell-terraform-provider/repos", 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "events_url": "https://api.github.com/orgs/kfcampbell-terraform-provider/events", 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "hooks_url": "https://api.github.com/orgs/kfcampbell-terraform-provider/hooks", 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "issues_url": "https://api.github.com/orgs/kfcampbell-terraform-provider/issues", 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "members_url": "https://api.github.com/orgs/kfcampbell-terraform-provider/members{/member}", 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "public_members_url": "https://api.github.com/orgs/kfcampbell-terraform-provider/public_members{/member}", 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "avatar_url": "https://avatars.githubusercontent.com/u/80981761?v=4", 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "description": "@kfcampbell uses this organization for testing work on the GitHub terraform provider", 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "name": "kfcampbell-terraform-provider", 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "company": null, 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "blog": null, 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "location": null, 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "email": null, 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "twitter_username": null, 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "is_verified": false, 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "has_organization_projects": true, 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "has_repository_projects": true, 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "public_repos": 43, 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "public_gists": 0, 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "followers": 0, 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "following": 0, 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "html_url": "https://github.com/kfcampbell-terraform-provider", 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "created_at": "2021-03-19T18:43:16Z", 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "updated_at": "2021-08-18T20:25:29Z", 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "type": "Organization" 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: }, 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: "parent": null 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: } 2021-11-18T10:47:34.789-0800 [DEBUG] provider.terraform-provider-github_v4.18.0: -----------------------------------------------------
I've also successfully done this by setting the GITHUB_OWNER and GITHUB_TOKEN environment variables instead of doing so in the provider block.
Can anybody experiencing this issue please try the above configuration and let me know if it works for you?
Still doesn't work for me unfortunately.
It seems within a module, if a "github" required_providers block is not defined, the (deprecated?) "hashicorp/github" provider is used.
For example, in order to resolve terraform's 404 errors to the github api, I needed to:
./main.tf
terraform {
required_version = ">= 1.0.5"
required_providers {
github = { // does not apply to modules
source = "integrations/github"
version = "4.20.0"
}
}
}
provider "github" {
app_auth {
id = 1234
installation_id = 5678
pem_file = var.github_app_pem_file
}
owner = "my-org-or-acct"
}
module "secrets" {
source = "./modules/secrets"
}
./modules/secrets/main.tf
terraform {
required_providers {
github = { // explicit provider block for github is required, else hashicorp/github source is used
source = "integrations/github"
version = "4.20.0"
}
}
}
data github_repository "some-repo" {
name = "some-repo"
}
// then some resource that uses data.github_repository.some-repo
If the github provider is not explicitly defined in the module, tf apply
will result in an error GET https://api.github.com/repos//some-repo: 404 Not Found []
.
It seems within a module, if a "github" required_providers block is not defined, the (deprecated?) "hashicorp/github" provider is used.
For example, in order to resolve terraform's 404 errors to the github api, I needed to:
./main.tf
terraform { required_version = ">= 1.0.5" required_providers { github = { // does not apply to modules source = "integrations/github" version = "4.20.0" } } } provider "github" { app_auth { id = 1234 installation_id = 5678 pem_file = var.github_app_pem_file } owner = "my-org-or-acct" } module "secrets" { source = "./modules/secrets" }
./modules/secrets/main.tf
terraform { required_providers { github = { // explicit provider block for github is required, else hashicorp/github source is used source = "integrations/github" version = "4.20.0" } } } data github_repository "some-repo" { name = "some-repo" } // then some resource that uses data.github_repository.some-repo
If the github provider is not explicitly defined in the module,
tf apply
will result in an errorGET https://api.github.com/repos//some-repo: 404 Not Found []
.
The above solution will not work as my data is in data.tf
and providers are in main.tf
. If I explicitly add a provider to data.tf
I get the following error:
A module may have only one required providers configuration. The required providers were previously configured at main.tf:2,3-21.
It seems within a module, if a "github" required_providers block is not defined, the (deprecated?) "hashicorp/github" provider is used. For example, in order to resolve terraform's 404 errors to the github api, I needed to:
./main.tf
terraform { required_version = ">= 1.0.5" required_providers { github = { // does not apply to modules source = "integrations/github" version = "4.20.0" } } } provider "github" { app_auth { id = 1234 installation_id = 5678 pem_file = var.github_app_pem_file } owner = "my-org-or-acct" } module "secrets" { source = "./modules/secrets" }
./modules/secrets/main.tf
terraform { required_providers { github = { // explicit provider block for github is required, else hashicorp/github source is used source = "integrations/github" version = "4.20.0" } } } data github_repository "some-repo" { name = "some-repo" } // then some resource that uses data.github_repository.some-repo
If the github provider is not explicitly defined in the module,
tf apply
will result in an errorGET https://api.github.com/repos//some-repo: 404 Not Found []
.The above solution will not work as my data is in
data.tf
and providers are inmain.tf
. If I explicitly add a provider todata.tf
I get the following error:A module may have only one required providers configuration. The required providers were previously configured at main.tf:2,3-21.
Moved all code to main.tf
. Still facing the issue. I encounter this issue when using app_auth
for authentication(token
works fine).
provider "github" {
app_auth {
id = var.app_id # or `GITHUB_APP_ID`
installation_id = var.app_installation_id # or `GITHUB_APP_INSTALLATION_ID`
pem_file = var.app_pem_file # or `GITHUB_APP_PEM_FILE`
}
}
It seems within a module, if a "github" required_providers block is not defined, the (deprecated?) "hashicorp/github" provider is used.
For example, in order to resolve terraform's 404 errors to the github api, I needed to:
./main.tf
terraform { required_version = ">= 1.0.5" required_providers { github = { // does not apply to modules source = "integrations/github" version = "4.20.0" } } } provider "github" { app_auth { id = 1234 installation_id = 5678 pem_file = var.github_app_pem_file } owner = "my-org-or-acct" } module "secrets" { source = "./modules/secrets" }
./modules/secrets/main.tf
terraform { required_providers { github = { // explicit provider block for github is required, else hashicorp/github source is used source = "integrations/github" version = "4.20.0" } } } data github_repository "some-repo" { name = "some-repo" } // then some resource that uses data.github_repository.some-repo
If the github provider is not explicitly defined in the module,
tf apply
will result in an errorGET https://api.github.com/repos//some-repo: 404 Not Found []
.
Hi, I'm using terraform cloud as remote backend and I can said none of the above solutions works for me, when using either local backend or s3 bucket it works just fine. Any hints/discoveries on this?
👋 Hey Friends, this issue has been automatically marked as stale
because it has no recent activity. It will be closed if no further activity occurs. Please add the Status: Pinned
label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!
I have a similar issue where I am trying to use the resource github_actions_environment_secret. The API returns a 404 with a repos// which should only be one / I have defined Owner/Repo and using a PAT with full access as a test and still get the error. Went on to define ../owner/repo which corrected the URL but still gives me a 404
Used the API directly to confirm the PAT and payload were correct and because I define the URL is worked 100%.
Seeing similar issues https://github.com/integrations/terraform-provider-github/issues/1805 https://github.com/pulumi/pulumi-github/issues/248
@nickfloyd any updates on this issue?
Using the github_team data source with the latest provider version returns 404.
Terraform Version
✗ terraform -v Terraform v0.13.6
Affected Resource(s)
Terraform Configuration Files
and the provider configuration
Debug Output
https://gist.github.com/eleni-salamani/bf0a8d0173700c95e6451ff6c78600a7
Panic Output
Expected Behavior
The data source should return the team information so that it can be used in further resources.
Actual Behavior
The call returns 404. It seems the API call is not built correctly as the organization is not set.
https://github.com/integrations/terraform-provider-github/blob/master/github/data_source_github_team.go#L57
Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
terraform apply
Important Factoids
References