Skip to content

github_actions_organization_secret always applies the value, even if it's unchanged #749

Closed

Description

@greggilbert

Terraform Version

Terraform v0.13.5

Affected Resource(s)

Please list the resources as a list, for example:

  • github_actions_organization_secret

Terraform Configuration Files

resource "github_actions_organization_secret" "this" {
  for_each = toset(local.secrets)

  secret_name     = each.value
  visibility      = "selected"
  plaintext_value = "(placeholder)"   # we'll change these values outside of Terraform

  selected_repository_ids = [
    for repo in data.github_repository.repos : repo.repo_id
  ]

  lifecycle {
    ignore_changes = [
      plaintext_value
    ]
  }
}

Expected Behavior

In this example, I'm giving providing a list of repositories that can access the secret. You can see I'm using (placeholder) as the plaintext value, with the idea that I would go into Github outside of TF and add in the real value once.

When I change the list of repositories, I expect that the real value I inputted would remain the same.

Actual Behavior

However, it actually replaces the real value with the placeholder.

Steps to Reproduce

  1. Use the github_actions_organization_secret resource to create a value like FOO with a default value of (placeholder)
  2. terraform apply the change/creation
  3. Go into your Github organization and edit the secret to have a value like Hello World
  4. Using the above config, modify the selected_repository_ids and apply the change
  5. In your Github Actions workflow, create a step like this:
      - name: DEBUG!
        env:
          MY_SECRET: ${{ secrets.FOO }}
        run: |
          echo ${MY_SECRET} | sed 's/./& /g' 
  6. Push and/or trigger the Github Action
  7. Note how the value that gets printed out is (placeholder) and not the expected Hello World

Activity

  1. added
    Type: Bug
    on Apr 13, 2021
  2. SanderKnape commented on Apr 30, 2021

    @SanderKnape

    We're running into this issue as well. Any thoughts on how this could be fixed?

  3. marcinwyszynski commented on Jun 2, 2021

    @marcinwyszynski
    Contributor

    Well, this is probably linked to my earlier fix. The whole idea of declaring resources with Terraform is for Terraform to make sure that the remote state matches the declared state. If you want Terraform to be blind to external changes, please explicitly set ignore_changes on this field.

  4. jvanbrunschot commented on Jul 5, 2021

    @jvanbrunschot

    I think that's the whole problem, that ignore_changes don't work.

  5. marcinwyszynski commented on Jul 5, 2021

    @marcinwyszynski
    Contributor

    @jvanbrunschot have you tried ignoring updated_at, too?

  6. jvanbrunschot commented on Jul 22, 2021

    @jvanbrunschot

    @marcinwyszynski sory for the slow response but adding both plaintext_valueand updated_at won't work either.

  7. sivapalan commented on Oct 8, 2021

    @sivapalan

    We also have a related use case where ignore_changes is not respected (after the change introduced in #740). In our case, we want to manage the secrets with Terraform, but use an external tool for managing selected_repository_ids for each secret.

    The updated_at field is updated each time a repository is added or removed from the list, so that makes this provider assume that the secret has been changed, and thereby forces a destroy and recreation of the secret.

    @jcudit What are your thoughts about introducing an additional attribute allowing users to choose the preferred behaviour?

    Example:

    destroy_on_drift - (Optional) Destroy and recreate secret if secret has been updated externally. Default is true.

  8. jcudit commented on Oct 17, 2021

    @jcudit
    Contributor

    @sivapalan that is a solid suggestion. Happy to help support an implementation if anyone wants to pick this up!

    From a code organization perspective, we've got a few different types of secrets that would benefit from such a flag. However, we've yet to refactor shared code for each secret type which may complicate or cause drift depending on how this gets implemented.

  9. yordis commented on Nov 5, 2022

    @yordis
    Contributor

    I gave it a try with #1351, but I am bending my brain regarding how to think about the unit-testing environment. I put some breakpoints to see how I could get to the resourceGithubActionsOrganizationSecretRead function, but no test ended up in resourceGithubActionsOrganizationSecretRead, so I can't learn from some examples.

    Some support is appreciated

  10. kfcampbell commented on Nov 10, 2022

    @kfcampbell
    Contributor

    @yordis how are you executing your unit tests? Would you mind sharing (redacted) environment variables and the command you're using to execute them?

    Side note: that drift-detection snippet is sprinkled all over our code. I wonder if there's a nice way to refactor that so the logic can be shared rather than duplicated.

  11. added
    Status: Needs info
    on Nov 15, 2022
  12. moved this to 🔥 Backlog in 🧰 Octokit Activeon Dec 5, 2022
  13. 7 remaining items

  14. yordis commented on Sep 23, 2023

    @yordis
    Contributor

    @o-sama did you get to test the binary?

  15. mm-bala commented on May 23, 2024

    @mm-bala

    Any update on this? It does not work yet.

  16. github-actions commented on Feb 18, 2025

    @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!

  17. added
    Status: Stale
    on Feb 18, 2025
  18. yordis commented on Feb 18, 2025

    @yordis
    Contributor

    bump

  19. removed
    Status: Stale
    on Feb 19, 2025
  20. moved this from Backlog to On Deck in Terraform Provideron Oct 14, 2025
  21. moved this from On Deck to In Progress in Terraform Provideron Oct 20, 2025
  22. moved this from In Progress to In Review in Terraform Provideron Oct 20, 2025
  23. moved this from 🛑 Blocked/Awaiting Response to ✅ Done in 🧰 Octokit Activeon Oct 20, 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: Needs infoType: Bugr/actions_secret

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions