-
Notifications
You must be signed in to change notification settings - Fork 769
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
Unable to create a repository in an organisation #876
Comments
Update:
So, the Update 2: So it works when I set GITHUB_OWNER. Am I correct to assume that if you use GITHUB_TOKEN env var, you also need to use the GITHUB_OWNER env var? |
I've encountered this same problem. Using the |
Seeing the same issue, which appears to be a regression from previous versions |
I faced this issue only when trying to create a repo in a child module. It doesn't pick up the org configuration from the parent module and you have to explicitly pass an aliased provider to the module. |
hi @serain , I'm facing the same issue within the module. Can you show an example of how you passed in the provider to the module? Just via a dedicated variable in the module or via the provider meta argument from the module (https://www.terraform.io/docs/language/meta-arguments/module-providers.html)? |
There is currently an issue with provider config: integrations/terraform-provider-github#876
There is currently an issue with provider config: integrations/terraform-provider-github#876
Same issue with current version ( It seems the documentation covering the usage of the In order to get it to work:
|
I've spent some time playing with this recently, and I'm not able to reproduce the issue. Here's a super pared-down template as an example: terraform {
required_providers {
github = {
source = "integrations/github"
version = "4.18.0"
}
}
}
provider "github" {
owner = "kfcampbell-terraform-provider"
token = "ghp_personal_token_redacted"
}
resource "github_repository" "app_repo" {
name = "876-repro"
description = "App repository"
visibility = "private"
delete_branch_on_merge = "true"
}
That repo has been created successfully here in my test organization rather than my personal profile. Can you try that reproduction and let me know if it works for you? |
Hi @kfcampbell , thanks for your reply 👋🏻 I just ran your example, changing the owner between my personal account, and an owned organization account, getting it to work in both. Then I tried switching my Perhaps I was confused with another Not sure, but it seems solved. |
I just encountered this with github provider 4.19.2, terraform 1.1.4. |
This problem occured for me with 4.20.1, settings the |
FWIW, this occurs only in the above situation. |
Had this problem, scratched my head on it for an hour or two, but @serain pointed me in the right direction. The child module didn't have a The child module of course wouldn't get the provider config because the providers don't match, leading to it thinking that the owner config was blank. To fix it, in your root module: terraform {
required_providers {
github = {
source = "integrations/github"
}
}
}
provider "github" {
owner = "YourOrgName"
token = "YourToken" // Or use ENV
} Then in the child module: terraform {
required_providers {
github = {
source = "integrations/github"
}
}
} |
@RulerOf this is something that's bitten multiple people. Would you (or anybody else) have any interest in creating a PR for our documentation that might explain the issue? |
@kfcampbell I could certainly take a stab at it, you can assign this issue to me if you like. Out of curiosity, this smells like an issue that should be resolved in core terraform. When terraform tries to guess providers based on resources, it should prioritize providers that are explicitly or implicitly passed from parent modules, and not... whatever it's doing presently. |
Agreed...I used to think (maybe still should think?) I had a misunderstanding of Terraform and now I'm super careful to add a This error is probably related to the transition of the provider from Hashicorp- to GitHub-owned. |
Thanks for giving it a shot! Please @ me on the PR if/when you get to it. |
Discussed over in #876, using implicit provider inheritance with this provider does not work, because terraform will prefer the `hashicorp/github` module by default. Tagging @kfcampbell who requested the PR :) Co-authored-by: Keegan Campbell <me@kfcampbell.com>
Initializing provider plugins...
|
…ns#1460) Discussed over in integrations#876, using implicit provider inheritance with this provider does not work, because terraform will prefer the `hashicorp/github` module by default. Tagging @kfcampbell who requested the PR :) Co-authored-by: Keegan Campbell <me@kfcampbell.com>
👋 Hey Friends, this issue has been automatically marked as |
Bump. |
Hello,
I'm trying to create a repository in an organisation using my personal access token. My config is something like this:
I have set the
GITHUB_TOKEN
to my PAT (which I granted all the permissions for now), but the repo still gets created under my own user-name, not onder my organisation.Now, maybe creating organisation repos doesn't work with PAT's, and I should use OAuth? But I have no clue on how to proceed with this. When trying to create a new GitHub OAuth app, it asks for a homepage URL and callback URL but I have no clue on what I should put here for TerraForm. The documentation is not clear on this either...
So, what is the correct approach here? I believe the documentation could be improved on this subject.
Terraform version: 1.0.3
Github provider version: 4.13.0
The text was updated successfully, but these errors were encountered: