You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support personal repositories not only GitHub organization #45
provider"github" {
token="${var.github_token}"
}
resource"github_repository""otus-devops-terraform" {
name="otus-devops-terraform"description="Repository for public terraform code using in Otus DevOps course"
}
resource"github_repository""practice-git-1" {
name="practice-git-1"description="Repository for practicing Git in Otus DevOps course"
}
resource"github_repository""practice-git-2" {
name="practice-git-2"has_issues=truedescription="Repository for practicing Git in Otus DevOps course"
}
It should create repository under personal account and write state in terraform.tfstate
Actual Behavior
terraform asks Github oraganization when running with terraform apply. Also it returns 422 when running twice. So it isn't idempotent.
Steps to Reproduce
terraform apply
Reacted by Christian Höltje, Võ Anh Duy, Nicolai Antiferov, Chris Forbes, Karl Q., AdamCavaliere, Brian Green, Kevin Hicks, Issy Long, Uzziah Eyee and 19 more
changed the title [-][FEATURE REQUEST] Support personal repositories not only GitHub organization[/-][+]Support personal repositories not only GitHub organization[/+]on Aug 31, 2017
the username is the github_orginization if you're operating under the personal/free account (it appears that in the GET Repos URL, the org argument sent to the provider is set as the owner in the request)
I was able to get tf import github_repo... to work with a personal access token.
I was able to run tf apply after importing and got a correct/successful "no changes needed"
I then tried to change the name of the repo in terraform, and am now getting: github_repository.test: POST https://api.github.com/orgs/kquinsland/repos: 404 Not Found []
Looking at the API Docs there is a different URL endpoint for creating in an org (POST /orgs/:org/repos) versus creating for a user (POST /user/repos. I'm very new to golang, is there a significant amount of work involved to add a simple account_type value to the provider, where a value of user informs the provider to use the user version of the necessary APIs and a value of org uses the APIs that are currently there?
Hello there,
Meanwhile waiting for a fix into GitHub Terraform provider. I have just released a Terraform module for anyone interested to set GitHup personal repositories. It's a bit raw, though.
$ terraform apply
...snip...
github_repository.test: Creating...
Error: This resource requires GitHub organization to be set on the provider.
on main.tf line 5, in resource "github_repository" "test":
5: resource "github_repository" "test" {
$ terraform import github_repository.test cornfeedhobo:go-travis-testing
github_repository.test: Importing from ID "cornfeedhobo:go-travis-testing"...
github_repository.test: Import prepared!
Prepared github_repository for import
github_repository.test: Refreshing state... [id=cornfeedhobo:terraform-github_branch-test]
Error: This resource requires GitHub organization to be set on the provider.
@cornfeedhobo you need to set individual = false in the provider config. That's kinda the weird thing here. The provider then treats your individual account as an org, so there will definitely be edge cases that don't work.
FYI - I moved the repo from my personal to an Org (the personal account owns) and all is now working. Same token with no perms changes. Provider 2.6.1.
Sorry, what is the fix here for the github_repository data source? Nothing I see described above seems to work. I'm on provider.github v2.9.2 and getting
Activity
jugatsu commentedon Aug 24, 2017
https://github.com/jugatsu/otus-devops-terraform
[-][FEATURE REQUEST] Support personal repositories not only GitHub organization[/-][+]Support personal repositories not only GitHub organization[/+]TraGicCode commentedon Sep 18, 2017
Any updates on this?
paultyng commentedon Mar 13, 2018
Related to #77
frostebite commentedon Jan 14, 2019
Any update on this? It would be great!
kquinsland01 commentedon Jan 19, 2019
the
usernameis thegithub_orginizationif you're operating under the personal/free account (it appears that in the GET Repos URL, the org argument sent to the provider is set as the owner in the request)I was able to get
tf import github_repo...to work with a personal access token.I was able to run
tf applyafter importing and got a correct/successful "no changes needed"I then tried to change the name of the repo in terraform, and am now getting:
github_repository.test: POST https://api.github.com/orgs/kquinsland/repos: 404 Not Found []Looking at the API Docs there is a different URL endpoint for creating in an org (
POST /orgs/:org/repos) versus creating for a user (POST /user/repos. I'm very new togolang, is there a significant amount of work involved to add a simpleaccount_typevalue to the provider, where a value ofuserinforms the provider to use the user version of the necessary APIs and a value oforguses the APIs that are currently there?phillip-bailey commentedon Mar 2, 2019
Having the possibilty to create and manage personal repositories from TF would be amazing, especially for demos. Any updates down the line?
phillip-bailey commentedon Mar 24, 2019
Hello there,
Meanwhile waiting for a fix into GitHub Terraform provider. I have just released a Terraform module for anyone interested to set GitHup personal repositories. It's a bit raw, though.
https://github.com/p0bailey/terraform-github-personal-repositories
binlab commentedon Jan 20, 2020
Any updates on this?
phillip-bailey commentedon Jan 23, 2020
Everything seems blocked.
ahaffar commentedon Mar 9, 2020
i am using
github_providerversion 2.4.1 and it works for individual reposwhere organization is the
usernamemrtazz commentedon Mar 25, 2020
this worked for me. With version
2.4.1configured for my individual account as above I was at least able to:cornfeedhobo commentedon Mar 29, 2020
I am unable to confirm @mrtazz's success:
Provider
Applying
Importing
Fixing this should close #50, #56, and #96.
@shoekstra @jcudit pinging you because I stumbled into this while attempting to test importing with
github_branch.mrtazz commentedon Mar 30, 2020
@cornfeedhobo you need to set
individual = falsein the provider config. That's kinda the weird thing here. The provider then treats your individual account as an org, so there will definitely be edge cases that don't work.12 remaining items
janaka commentedon Apr 17, 2020
Pretty sure perms are good. I'll need to double check as it's been some days.
janaka commentedon Apr 18, 2020
FYI - I moved the repo from my personal to an Org (the personal account owns) and all is now working. Same token with no perms changes. Provider 2.6.1.
abitrolly commentedon Jun 22, 2020
@jcudit can you add this to v2.9.0 https://github.com/terraform-providers/terraform-provider-github/milestone/8?closed=1 milestone?
clebio commentedon Aug 12, 2020
Sorry, what is the fix here for the
github_repositorydata source? Nothing I see described above seems to work. I'm onprovider.github v2.9.2and gettingcornfeedhobo commentedon Aug 12, 2020
@clebio pretty sure this was reverted
janaka commentedon Aug 13, 2020
Given orgs became free around the same time, I just created one and moved my repo there.
josjaf commentedon Aug 23, 2020
I'm now having the issue - @cornfeedhobo - how do you know it was reverted? I cannot easily create an organization because I'm part of a few already.
cornfeedhobo commentedon Aug 24, 2020
@josjaf hashicorp/terraform-provider-github@v2.9.0...v2.9.1
josjaf commentedon Sep 1, 2020
Any idea what the workaround is for personal repositories for now?
cornfeedhobo commentedon Sep 2, 2020
@josjaf there is none that I know of right now. Sounds like most people have created orgs for the meantime.
abitrolly commentedon Sep 3, 2020
@josjaf I moved to GitLab.
GitHub Terraform provider is being annoying =(
ggsood commentedon Dec 25, 2020
This issue is now resolved now as per the provider version v4.1.0, you can create a github repo in your personal profile as
Thanks Community for fixing this issue.