Skip to content

When github_actions_secret is changes via gui, it will be re-created #964

Description

@ArneRiemann4711

Terraform Version

1.0.7

Affected Resource(s)

Please list the resources as a list, for example:

  • github_actions_secret

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Terraform Configuration Files

resource "github_actions_secret" "workflow_pat" {

  count = var.create_default_secrets ? 1 : 0

  repository      = github_repository.this.name
  secret_name     = "WORKFLOW_PAT"
  plaintext_value = "CHANGE_ME"

  lifecycle {
    ignore_changes = [plaintext_value]
  }
}

Expected Behavior

Changes to Secrets made from GitHub Gui should be ignored

Actual Behavior

Secret will be re-created

Steps to Reproduce

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

  1. terraform apply

Repo is created from a template. Could this be the reason?

Activity

  1. thekbb commented on Nov 2, 2021

    @thekbb
    Contributor

    This is expected, terraform is fixing config drift. Changes to a terraform managed resource made outside of terraform will be put back when terraform applies.

    Things should either be managed through terraform or not... there is no middle path.

  2. gfoligna-nyshex commented on Nov 5, 2021

    @gfoligna-nyshex

    I think the ignore_changes lifecycle argument is there on purpose.

    I'm having the same issue. I get a total new creation of the github_actions_secret every time I plan and apply.
    None of the arguments from ignore_changes works for me.

    TF ver 0.13.5
    GitHub provider ver 4.7.0 (latest as of today)

    This is expected, terraform is fixing config drift. Changes to a terraform managed resource made outside of terraform will be put back when terraform applies.

    Things should either be managed through terraform or not... there is no middle path.

  3. gfoligna-nyshex commented on Nov 5, 2021

    @gfoligna-nyshex

    Also this relates to #749

  4. gfoligna-nyshex commented on Nov 5, 2021

    @gfoligna-nyshex

    One more thing: v0.14.1 claims to have this error fixed. Tested and it is still not working (actually just worked once).

  5. atanaspam commented on Nov 8, 2021

    @atanaspam

    We are also running into this issue.

    Seems to be related to this piece of code that does not respect the ignore_changes lifecycle argument.

  6. yordis commented on Nov 5, 2022

    @yordis
    Contributor

    Following this,

    Our intention at the moment is to provision the secrets without the values (just as a templating) to then manually update the secret values, but every time we do it the resource gets destroyed and recreated again.

  7. github-actions commented on Aug 3, 2023

    @github-actions

    👋 Hey Friends, this issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please add the Status: Pinned label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!

  8. added
    Status: Stale
    on Aug 3, 2023
  9. yordis commented on Aug 3, 2023

    @yordis
    Contributor

    keep

  10. removed
    Status: Stale
    on Aug 4, 2023
  11. github-actions commented on May 3, 2024

    @github-actions

    👋 Hey Friends, this issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please add the Status: Pinned label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!

  12. added
    Status: Stale
    on May 3, 2024
  13. yordis commented on May 3, 2024

    @yordis
    Contributor

    Could somebody try to directly help at #1351

  14. added
    Status: Pinned
    and removed
    Status: Stale
    on May 3, 2024
  15. 2 remaining items

  16. moved this from 🆕 Triage to 🔥 Backlog in 🧰 Octokit Activeon May 3, 2024
  17. mrsaiz commented on May 8, 2024

    @mrsaiz

    We are also facing this issue. In AWS terraform provider, the way it is manage is using two different resources, secret and secret_version.

    resource "aws_secretsmanager_secret" "example" {
      name = "example"
    }
    
    resource "aws_secretsmanager_secret_version" "example" {
      secret_id     = aws_secretsmanager_secret.example.id
      secret_string = "example-string-to-protect"
    }

    I can create an "empty" secret with terraform, then manage the secret_version out of terraform state.

    It would be nice to manage github secrets in a similar way. The day 1, I want to create the secret with terraform but, day 2, manage the rotation with a separated tool.

  18. moved this from Backlog to On Deck in Terraform Provideron Oct 14, 2025
  19. nickfloyd commented on Oct 27, 2025

    @nickfloyd
    Contributor

    This feels like another destroy_on_drift scenario much like this recent changeset. My guess from the discussion is that we need to add the property to resourceGithubActionsSecret for those who want to override the default behavior. I can work up a PR but I'd like another confirmation as a gut check to ensure I'd be addressing the actual need here.

    I'll work something up with schema migrations as well to help to close this out.

  20. moved this from On Deck to In Progress in Terraform Provideron Oct 28, 2025
  21. moved this from In Progress to In Review in Terraform Provideron Oct 28, 2025
  22. moved this from 🔥 Backlog to ✅ Done in 🧰 Octokit Activeon Oct 29, 2025
  23. moved this from Done to In Progress in Terraform Provideron Oct 29, 2025
  24. moved this from In Progress to Done in Terraform Provideron Nov 12, 2025
  25. oskarsword commented on Dec 10, 2025

    @oskarsword

    I dont think it was implemened for github environment secrets.

    This is the comment inside github environment secret resource:

    if updatedAt, ok := d.GetOk("updated_at"); ok && updatedAt != secret.UpdatedAt.String() {

    // This is a drift detection mechanism based on timestamps.
    //
    // If we do not currently store the "updated_at" field, it means we've only
    // just created the resource and the value is most likely what we want it to
    // be.
    //
    // If the resource is changed externally in the meantime then reading back
    // the last update timestamp will return a result different than the
    // timestamp we've persisted in the state. In that case, we can no longer
    // trust that the value (which we don't see) is equal to what we've declared
    // previously.
    //
    // The only solution to enforce consistency between is to mark the resource
    // as deleted (unset the ID) in order to fix potential drift by recreating
    // the resource.
    

    Why doesnt it respect prevent_destroy / ignore_changes?

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: Pinned

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions