You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
github_actions_organization_secret always applies the value, even if it's unchanged #749
resource"github_actions_organization_secret""this" {
for_each=toset(local.secrets)
secret_name=each.valuevisibility="selected"plaintext_value="(placeholder)"# we'll change these values outside of Terraformselected_repository_ids=[
forrepoindata.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
Use the github_actions_organization_secret resource to create a value like FOO with a default value of (placeholder)
terraform apply the change/creation
Go into your Github organization and edit the secret to have a value like Hello World
Using the above config, modify the selected_repository_ids and apply the change
In your Github Actions workflow, create a step like this:
Note how the value that gets printed out is (placeholder) and not the expected Hello World
Reacted by Sander Knape, Jamie van Brunschot, Ken Clarke, Jeremy Witte, Andy Gimblett, Ian McCausland, Eligio Mariño, Sayali Mohadikar, Balaji V, Garret Pick and 1 more
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.
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.
Reacted by Marcin Wyszynski, Jeremy Udit, Gonzalo Foligna, Ken Clarke, Josh Gubler and Bart Lisiecki
@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.
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.
@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.
👋 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!
Activity
SanderKnape commentedon Apr 30, 2021
We're running into this issue as well. Any thoughts on how this could be fixed?
marcinwyszynski commentedon Jun 2, 2021
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_changeson this field.jvanbrunschot commentedon Jul 5, 2021
I think that's the whole problem, that
ignore_changesdon't work.marcinwyszynski commentedon Jul 5, 2021
@jvanbrunschot have you tried ignoring
updated_at, too?jvanbrunschot commentedon Jul 22, 2021
@marcinwyszynski sory for the slow response but adding both
plaintext_valueandupdated_atwon't work either.sivapalan commentedon Oct 8, 2021
We also have a related use case where
ignore_changesis 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 managingselected_repository_idsfor each secret.The
updated_atfield 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:
jcudit commentedon Oct 17, 2021
@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.
yordis commentedon Nov 5, 2022
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
resourceGithubActionsOrganizationSecretReadfunction, but no test ended up inresourceGithubActionsOrganizationSecretRead, so I can't learn from some examples.Some support is appreciated
kfcampbell commentedon Nov 10, 2022
@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.
7 remaining items
yordis commentedon Sep 23, 2023
@o-sama did you get to test the binary?
mm-bala commentedon May 23, 2024
Any update on this? It does not work yet.
github-actions commentedon Feb 18, 2025
👋 Hey Friends, this issue has been automatically marked as
stalebecause it has no recent activity. It will be closed if no further activity occurs. Please add theStatus: Pinnedlabel if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!yordis commentedon Feb 18, 2025
bump