Repository navigation
Closed
Labels
Status: PinnedA way to keep old or long lived issues aroundStatus: Up for grabsIssues that are ready to be worked on by anyoneType: BugSomething isn't working as documentedVisibility
Milestone
Description
Hi there,
Terraform Version
1.0.5
Affected Resource(s)
- github_repository
Terraform Configuration Files
# create github repository for the domain under domain team
resource "github_repository" "domain" {
name = lower("${var.domain}-domain")
visibility = "internal"
template {
owner = "our-enterprise-org-id"
repository = "tf-domain-template"
}
}Debug Output
NOTE: I removed the sensible parts from the logs. Still, I think the logs shows what's the actual issue. Let me recap it here:
- We're using TF to create a GitHub repo out of a template.
- The template repo visibility is set to
Internal. - The newly created repo visibility should be
Internalas well. - The repo gets created, but it remains
Privateand the visibility setup phase fails with error 422.
Panic Output
n/a
Expected Behavior
I'd expect a new repo with visibility Internal being created.
Actual Behavior
The terraform apply fails with error code 422 on visibility change step.
Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
- Set org policy to prevent users from changing repos visibility.
- Create a template repo with visibility
Internal - Use the provided TF code for creating a new repo with visibility
Internalout of the template one. - Use a GitHub App identity with scopes listed below.
- Run
terraform apply.
Important Factoids
- We're running TF with GitHub Apps credentials with following scopes:
- Repository access: All repositories
- Repository permissions:
- Administration: r/w
- Contents: r/w
- Metadata: ro
- Secrets: r/w
- Organization permissions:
- Members: r/w
- Administration: r/w
- Our Enterprise has an Org.Policy set that prevents users from creating Public repos, as well only Org.Owners are allowed to change repos visibility.
References
n/a
Reacted by Nicholas Drone, Mark Adamson, Jiri Tyr, Stefan Parviainen, Fran R, Jess Rhodes, Tommaso Resti, Maciej Józefczyk, Varun Sivapalan, Scott Doyland and 7 more
Metadata
Metadata
Assignees
Labels
Status: PinnedA way to keep old or long lived issues aroundStatus: Up for grabsIssues that are ready to be worked on by anyoneType: BugSomething isn't working as documentedVisibility
Type
Projects
- StatusShow more project fieldsDone
Activity
erzz commentedon Oct 13, 2021
Basically a me too post - but just to add that I get the same result from the same TF config using 1.0.7 too
parviste-fortum commentedon Feb 10, 2022
The issue seems to be due to a limitation in the Github API which only supports public and private creation from a template: https://docs.github.com/en/rest/reference/repos#create-a-repository-using-a-template
Of course, it might be nice if terraform would give and error or at least warning when trying to set visibility to internal, instead of sillently ignoring it:
terraform-provider-github/github/resource_github_repository.go
Lines 329 to 330 in 98dddd2
parviste-fortum commentedon Feb 11, 2022
Seems like the Github GraphQL API does support creating internal repos from templates: https://docs.github.com/en/graphql/reference/input-objects#clonetemplaterepositoryinput
JafoFett commentedon May 27, 2022
Hoping there is a way to create 'internal' repo's from template repo using Terraform...is there a workaround for the API limitation? Or a flat out no go?
github-actions commentedon Feb 22, 2023
👋 Hey Friends, this issue has been automatically marked as
stalebecause it has no recent activity. It will be closed if no further activity occurs. Please add theStatus: Pinnedlabel if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!damir-dezeljin commentedon Feb 22, 2023
How can I set the
Status: Pinnedlabel? I think this is quite a serious flow for Enterprise Cloud customers requiring no repository is set toPublicand therefore setting an Org policy for that, but on the other hand wanting all terraformed repositories being accessible to all employees.I'd appreciate a feedback from GitHub on the matter.
kfcampbell commentedon Feb 28, 2023
@damir-dezeljin apologies, the SDK team is spread pretty thin at the moment. We've got a little bit of content here about our prioritization process, but realistically, the best way to address this problem is to submit a PR following our contributing guidelines to this project. We appreciate all contributions!
ZarakiKenpachi7 commentedon Aug 1, 2025
Hi - ANy updates here? It has been more than 2 years.
deiga commentedon Jan 18, 2026
@ZarakiKenpachi7 I just tried creating an internal repo from template and had no issues. Could you provide a config example of what is failing for you and some debug output?
mungojam commentedon Jan 18, 2026
@deiga did you do this step in the repro?
FlaviusRaducu commentedon Jan 26, 2026
Same problem here, visibility defaults to public; it looks like the bug was fixed in v4.9.4 with this PR but reintroduced in v6.10.0 with this PR.
v6.9.1
>= v6.10.0