Search code examples
githubterraformterraform-provider-github

terraform 1.0.0 strange message about github repository ETAG changed


terraform 1.0.0

terraform plan displays the following message

Note: Objects have changed outside of Terraform

Terraform detected the following changes made outside of Terraform since the last "terraform
apply":

  # module.webrefresh-wordpress.github_repository.repository[0] has been changed
  ~ resource "github_repository" "repository" {
      ~ etag                   = "W/\"0a6acc64db34a0ae0d3ed9e6931dcc845ad0cf5f60113a6df4749c111b20a93a\"" -> "W/\"d1955c8eecde028f7360e767340e809796f6fb18b3c0a6bb0091d395334029df\""
        id                     = "test-webrefresh-wordpress"
        name                   = "test-webrefresh-wordpress"
        # (26 unchanged attributes hidden)
    }

Unless you have made equivalent changes to your configuration, or ignored the relevant
attributes using ignore_changes, the following plan may include actions to undo or respond to
these changes.

──────────────────────────────────────────────────────────────────────────────────────────────

No changes. Your infrastructure matches the configuration.

So how to get rid of it?

Tried with terraform apply -refresh-only but it didn't help.

this is my tf code block:


resource "github_repository" "repository" {
  count       = length(local.to_create_repositories)
  name        = local.to_create_repositories[count.index].name
  description = title(local.to_create_repositories[count.index].description)

  visibility             = local.to_create_repositories[count.index].github_visibility
  has_issues             = local.to_create_repositories[count.index].has_issues != null ? local.to_create_repositories[count.index].has_issues : true
  has_wiki               = local.to_create_repositories[count.index].has_wiki != null ? local.to_create_repositories[count.index].has_wiki : true
  allow_merge_commit     = local.to_create_repositories[count.index].allow_merge_commit != null ? local.to_create_repositories[count.index].allow_merge_commit : true
  allow_rebase_merge     = local.to_create_repositories[count.index].allow_rebase_merge != null ? local.to_create_repositories[count.index].allow_rebase_merge : true
  delete_branch_on_merge = local.to_create_repositories[count.index].delete_branch_on_merge != null ? local.to_create_repositories[count.index].delete_branch_on_merge : true
  auto_init              = local.to_create_repositories[count.index].auto_init != null ? local.to_create_repositories[count.index].auto_init : true
  archive_on_destroy     = true

  lifecycle {
    ignore_changes = [etag]
  }
}

Solution

  • This is being tracked in the github provider as an issue relying on some upstream behaviour to be considered.

    The upstream issue in Terraform core is particularly worth reading about to see why this is happening.

    In your case as long as you don't have anything referencing the etag output (which would be surprising) then you can safely ignore this as it's just a computed attribute. You can also remove that lifecycle.ignore_changes = [etag] block because it doesn't impact computed attributes as it's not something settable by that resource.