Skip to content

provider wants to endlessly change the branches attribute of github_repository resource when repo is archived #1037

@dimisjim

Description

@dimisjim

Hey,

What the title says basically. The provider keeps trying to change the branches attribute of the github_repository resource, when the repo is archived. Even after applying, which outputs no error, the drift persists.

I presume this is related to the fact that even via the UI, when a repo is archived, it is read-only and thus branches config cannot change. So when visiting https://github.com/$org/$repo$/settings/branches one gets this message:
image

Terraform Version

1.1.2

Affected Resource(s)

  • github_repository

Terraform Configuration Files

resource "github_repository" "r" {
  name                   = var.name
  description            = var.description
  visibility             = var.visibility
  homepage_url           = var.homepage_url
  allow_merge_commit     = var.allow_merge_commit
  allow_squash_merge     = var.allow_squash_merge
  allow_rebase_merge     = var.allow_rebase_merge
  vulnerability_alerts   = var.vul_alerts
  has_downloads          = var.has_downloads
  has_issues             = var.has_issues
  archived               = var.archived
  archive_on_destroy     = var.archive_on_destroy
  topics                 = var.topics
  is_template            = var.is_template
  delete_branch_on_merge = var.delete_br_on_merge
  auto_init              = true
  allow_auto_merge       = var.allow_auto_merge
  
  dynamic "template" {
    for_each = length(var.template_name) > 0 ? [""] : []
    
    content {
      owner      = "$redacted"
      repository = var.template_name
    }
  }

  lifecycle {
    ignore_changes = [auto_init]
  }
}

Expected Behavior

No drift to be outputted

Actual Behavior

  # module.repo_test-repo.github_repository.r will be updated in-place
  ~ resource "github_repository" "r" {
      + branches               = (known after apply)
        id                     = "$redacted"
        name                   = "$redacted"
        # (28 unchanged attributes hidden)
    }

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. import an archived repo (or archive it after creating it via terraform)
  2. plan
  3. see drift being outputted
  4. issue is mitigated when branches is included in the ignore_changes array, but this could lead to other issues too

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions