Repository navigation
Closed
Description
Hi there,
Terraform Version
Terraform v1.1.9
Affected Resource(s)
- github_repository
Terraform Configuration Files
resource "github_repository" "repository" {
for_each = var.repositories
name = each.key
description = each.value.description
homepage_url = each.value.homepage_url
allow_merge_commit = each.value.allow_merge_commit
allow_rebase_merge = each.value.allow_rebase_merge
allow_squash_merge = each.value.allow_squash_merge
has_downloads = each.value.has_downloads
has_issues = each.value.has_issues
has_projects = each.value.has_projects
has_wiki = each.value.has_wiki
vulnerability_alerts = each.value.vulnerability_alerts
visibility = each.value.visibility == null ? "private" : each.value.visibility
lifecycle {
ignore_changes = [
# branches are very slow to update and unused anyway
branches,
]
}
}
Expected Behavior
- use value from repository by default when there no such field in definition
Actual Behavior
- errors, need to rerun apply to remove errors
Steps to Reproduce
Organization with forks disabled, private repository, 4.23.0 of provider
then update provider (without adding allow_forking) and apply
Error: PATCH https://api.github.com/repos/org/repo: 422 This organization does not allow private repository forking []
with github_repository.repository["repo"],
on github-main.tf line 8, in resource "github_repository" "repository":
8: resource "github_repository" "repository" {
but if run apply second time - everything is fine (and state has allow_forking == true, while really forking is disabled)
then if I disable allow_forking explicitly the error returns
allow_forking = false # forcefully disable forks
output
Error: PATCH https://api.github.com/repos/org/repo: 422 This organization does not allow private repository forking []
with github_repository.repository["repo"],
on github-main.tf line 8, in resource "github_repository" "repository":
8: resource "github_repository" "repository" {
but again if run apply second time , then everything is fine
References
Reacted by Richard Burge, Jordy Ruiter, Jared Holgate, barezkiBM, Iiro Niinikoski, David Fleming, Kostiantyn Vorobiov and Felipe Tomazelli
Metadata
Metadata
Assignees
Labels
No labels
Activity
sksat commentedon Apr 29, 2022
I have the same problem...(on organization repository and my personal repository)
Ka1wa commentedon Apr 29, 2022
Not much to add to the original issue here. Very much in the same boat, we tried rolling back to an older provider version but that is also giving headaches because of the massive amounts of repositories we manage.
uportalis commentedon Apr 29, 2022
Same problem for me. This prevents me to create a new repository with terraform because, even when I run plan/apply twice.
I had to temporary allow forking private repositories for my organization to make the plan/apply success (and switched it back to disallow right after).
davidfleming commentedon Apr 29, 2022
Running into this issue as well. I would expect it to default to false which is the same functionality as the UI. Looking through the API I don't see anywhere that explicitly states that it defaults to true. In fact it doesn't appear to be documented for create -> https://docs.github.com/en/rest/repos/repos#create-an-organization-repository
tomazellifelipe commentedon Apr 29, 2022
Same problem here.
kfcampbell commentedon Apr 29, 2022
Sorry about that folks! I've reverted the offending PR and published v4.24.1 with only that change in it.
fix(github_repository): Skip allow_forking for personal repos