Skip to content

continual changes detected due to changing etag #796

Closed

Description

@StephenWithPH

Terraform Version

Terraform v0.15.4
on linux_amd64
+ provider registry.terraform.io/integrations/github v4.9.4

Affected Resource(s)

  • github_repository

Expected Behavior

After a successful terraform apply, subsequent terraform plan or terraform apply should detect no changes and have nothing to do.

Actual Behavior

Every terraform plan or terraform apply after creating the resource shows:

Note: Objects have changed outside of Terraform

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

  # github_repository.foo has been changed
  ~ resource "github_repository" "foo" {
      ~ etag                   = <some value> -> <some other value>
        id                     = "foo"
        name                   = "foo"
        # (23 unchanged attributes hidden)
    }

Steps to Reproduce

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

  1. terraform apply to create a GitHub repo
  2. terraform apply again and see the above warning regarding changes to etag

Important Factoids

Because etag is not exposed on the github_repository resource, it's not possible to mark it to be ignored.

Activity

  1. sdomula commented on May 21, 2021

    @sdomula
    Contributor

    I ran into the same problem after upgrading to Terraform 0.15.4. Deleting the repositories from the state with terraform state rm and then importing them with terraform import did not solve this issue. The ETag is still reported to be changed outside of Terraform.

  2. mbainter commented on May 25, 2021

    @mbainter

    JIC - I also experience this problem on 0.15.4 and integrations/github v4.10

  3. added
    Type: Bug
    on Jun 3, 2021
  4. loozhengyuan commented on Jun 9, 2021

    @loozhengyuan
    Contributor

    I just encountered this after upgrading from 0.15.0 to 1.0.0. Interestingly, no changes were proposed even when Terraform detected a drift on the etag field:

    $ terraform plan
    Acquiring state lock. This may take a few moments...
    ...
    
    Note: Objects have changed outside of Terraform
    
    Terraform detected the following changes made outside of Terraform since the last "terraform apply":
    
      # github_repository.foo has been changed
      ~ resource "github_repository" "foo" {
          ~ etag                   = <some value> -> <some other value>
            id                     = "foo"
            name                   = "foo"
            # (23 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.
    
    Your configuration already matches the changes detected above. If you'd like to update the Terraform state to match, create and apply a refresh-only plan:
      terraform apply -refresh-only
    Releasing state lock. This may take a few moments...

    This behaviour seems consistent and expected as per the discussion on hashicorp/terraform#28803. As noted in the issue, using ignore_changes will not have an impact on this either.

    I don't think there is much we can do at a provider-level to mitigate this, so I propose that we close this issue and track hashicorp/terraform#28803 in the upstream project.

  5. jcudit commented on Jun 15, 2021

    @jcudit
    Contributor

    Thanks for surfacing this information 🙇🏾

    Pretty concerning from a performance perspective, so open to more ideas and can prioritize fixes accordingly.

  6. ChristophShyper commented on Sep 9, 2021

    @ChristophShyper

    Ignoring this issue is not a good solution for many.
    I'm running drift detection and it shows up all the time taking unnecessary time to investigate on each run.

  7. mbainter commented on Sep 9, 2021

    @mbainter

    They're not really ignoring the issue - they're just pointing out that ultimately the provider is working as expected, and terraform isn't honoring it as an expected change that should simply be updated in state quietly -- so ultimately it's on hashicorp to fix this. (Because they're not even accepting PRs from the community right now)

  8. MOZGIII commented on Sep 12, 2021

    @MOZGIII

    Why not just remove etag from the state? I mean, it is a possible solution at a provider level.

  9. jcudit commented on Sep 12, 2021

    @jcudit
    Contributor

    It's value is passed through to the HTTP If-None-Match header when reading API resources, so good to store across Terraform runs. 🤔 maybe we could add a DiffSuppressFunc to the etag field if there are no objections to making the etag internals less transparent.

  10. loozhengyuan commented on Sep 12, 2021

    @loozhengyuan
    Contributor

    I think that the etag field is not particularly useful to end-users, so implementing DiffSuppressFunc should be a good approach to workaround this issue. Suppressing the etag field should not render changes to the other fields any less noticeable too.

  11. added this to the v4.16.0 milestone on Sep 13, 2021
  12. modified the milestones: v4.16.0, v4.15.0 on Sep 21, 2021
  13. 39 remaining items

  14. irizzant commented on Dec 23, 2024

    @irizzant

    I agree this is a very annoying issue, as there is no field for etag in the resource itself and cannot be ignored.
    This is bad

  15. syhe commented on Jan 8, 2025

    @syhe

    As per hashicorp/terraform-plugin-sdk#1355 (comment) , the culprit is ultimately the usage of the old SDK version without support for private state, as detailed in #1912 .

    Now, it seems to me that with #1780 the migration to the new SDK was done and released with version 6.

    Some resources now export etag as an attribute one can use in ignore_changes, but most, like for example github_repository, still only include it as computed attribute, which cannot be used in ignore_changes.

    What is stopping the use of private state for this (and possibly other) attribute(s)?

  16. sl4m commented on Jul 3, 2025

    @sl4m

    @syhe AFAICT, #1780 did not migrate over to the plugin Framework, but upgraded to v2 in the legacy SDK. #1912 is still open.

  17. added a commit that references this issue on Sep 4, 2025
  18. moved this from Backlog to On Deck in Terraform Provideron Oct 14, 2025
  19. nickfloyd commented on Oct 29, 2025

    @nickfloyd
    Contributor

    Based on the version of the SDK that we are currently using (terraform-plugin-sdk/v2 v2.34.0) we should be able to go with the initial approach (even on computed fields) of:

    DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
        return true
    },
    

    And add DiffSuppressOnRefresh: true as well to suppress the diff between config and state.

    Lastly these fields have to be marked as Optional=true - SDK ref

    Computed-only fields: Computed: true, Optional: false → Can't have DiffSuppressFunc
    Optional computed fields: Computed: true, Optional: true → Can have DiffSuppressFunc
    

    I believe we can set this to always returns true - which should suppress all etag diffs; this should also work for refresh operations as well.

    This approach should be safe because ETags are internal concerns, not user configuration, ETags are still stored and used for API optimization by the SDK / provider, and all user changes to actual resource attributes are still detected normally.

    Let me put a quick PR together to illustrate this and see if everyone agrees with the approach. The better move would be to migrate to the Plugin Framework but for now we can get this cleaned up a bit as is.

  20. moved this from On Deck to In Progress in Terraform Provideron Oct 29, 2025
  21. nickfloyd commented on Oct 29, 2025

    @nickfloyd
    Contributor

    Here's what I was thinking: #2840 - I'll write up some tests to go with it but I think this approach is sound - please ✅ on the PR if you agree and I'll move to add this to the next release. ❤️

  22. moved this from In Progress to In Review in Terraform Provideron Oct 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: Up for grabsType: Bughacktoberfestr/repository

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions