terraform-provider-github icon indicating copy to clipboard operation
terraform-provider-github copied to clipboard

[BUG]: Imported repos have drift on template item

Open vlatko-b opened this issue 1 year ago • 3 comments

Expected Behavior

My code works fine for creating new repos but if I import existing one it shows constant drift

  ~ resource "github_repository" "repo" {
        id                          = "pizza"
        name                        = "pizza"
        # (36 unchanged attributes hidden)

      + template {
          + include_all_branches = false
          + owner                = "XXX"
          + repository           = "github-repo-template"
        }
    }

Plan: 0 to add, 1 to change, 0 to destroy.

They are not created from a template. Is there a way to prevent this without creating a different resource for these that are not based on template?

Actual Behavior

There is no way to set template after repo is created on blank but TF tries to do it

Terraform Version

Terraform v1.4.6 on linux_amd64

  • provider registry.terraform.io/hashicorp/aws v3.76.1
  • provider registry.terraform.io/integrations/github v6.5.0

Affected Resource(s)

github_repository

Terraform Configuration Files

resource "github_repository" "repo" {
  name                        = var.name
   ...
  topics                      = ["managed-by-terraform"]

  template {
    owner                = "XXX"
    repository           = "github-repo-template"
    include_all_branches = false
  }
}

Steps to Reproduce

terraform plan

after a non templated repo is imported

Debug Output


Panic Output


Code of Conduct

  • [x] I agree to follow this project's Code of Conduct

vlatko-b avatar Feb 07 '25 13:02 vlatko-b

In a strange way after 2 TF apply commands the drift goes away

vlatko-b avatar Feb 07 '25 15:02 vlatko-b

For a while, but always seems to come back eventually :/.

Blacksmoke16 avatar May 20 '25 04:05 Blacksmoke16

Also seeing this behaviour

gabrielsoltz avatar May 21 '25 11:05 gabrielsoltz

I’ve experienced the same issue when creating a new repository from a template — the diff always appears.

meraj-kashi avatar Aug 26 '25 12:08 meraj-kashi