Skip to content

Failed setting visibility=internal on a newly created repo from template #925

@damir-dezeljin

Description

@damir-dezeljin

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

Gist: https://gist.github.com/damir-dezeljin/e9de28e11aa7de8d7a60fc2e123794f6

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 Internal as well.
  • The repo gets created, but it remains Private and 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:

  1. Set org policy to prevent users from changing repos visibility.
  2. Create a template repo with visibility Internal
  3. Use the provided TF code for creating a new repo with visibility Internal out of the template one.
  4. Use a GitHub App identity with scopes listed below.
  5. 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

Metadata

Metadata

Assignees

No one assigned

    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

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions