Skip to content

Using github_actions_organization_secret_repositories causes to be updated on each apply even with no changes. #974

Closed as not planned

Description

@MitchellGerdisch

Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.

Terraform Version

Terraform v0.15.0

Affected Resource(s)

Please list the resources as a list, for example:

  • github_actions_organization_secret
  • github_actions_organization_secret_repositories

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

Terraform Configuration Files

terraform {
  required_providers {
    github = {
      source  = "integrations/github"
      version = "~> 4.0"
    }
  }
}
# Configure the GitHub Provider
provider "github" {}

data "github_repository" "repo" {
  full_name = "ORGNAME/REPONAME" # Change accordingly
}

resource "github_actions_organization_secret" "example_secret" {
  secret_name             = "example_secret_name"
  visibility              = "selected"
  plaintext_value         = "my-secret-text"
  # selected_repository_ids = [data.github_repository.repo.repo_id]
}

resource "github_actions_organization_secret_repositories" "org_secret_repos" {
  secret_name = "example_secret_name"
  selected_repository_ids = [data.github_repository.repo.repo_id]
}

Debug Output

Please provide a link to a GitHub Gist containing the complete debug output: https://www.terraform.io/docs/internals/debugging.html. Please do NOT paste the debug output in the issue; just paste a link to the Gist.

Panic Output

If Terraform produced a panic, please provide a link to a GitHub Gist containing the output of the crash.log.

Expected Behavior

Using the above code with no changes should not keep updating the secret on apply.

Actual Behavior

The first apply works as expected and then each subsequent apply indicates an update and applies an update even though no code was changed.
If instead of using the separate github_actions_organization_secret_repositories resource and instead embed the respositories as part of the github_actions_organization_secret resource, this does not happen.

Steps to Reproduce

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

  1. terraform apply
  2. see the resource was created as expected in github.
  3. Wait a minute and refresh the github page so you can see the secret was created a minute ago.
  4. terraform apply
  5. See that terraform is showing an update even though nothing has changed.
  6. Accept the update
  7. Confirm that github shows the same secret was just updated.
  8. terraform destroy
  9. Change the code to comment out the secret_repositories resource and uncomment the embedded repositories property int he secret resource.
  10. terraform apply
  11. See the secret was created as expected
  12. terrarorm apply
  13. See that it does not try to update the unchanged resource as expected.

Important Factoids

Is there anything atypical about your accounts that we should know? For example: Running in EC2 Classic? Custom version of OpenStack? Tight ACLs?

References

Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:

Activity

  1. added
    Type: Bug
    on Dec 30, 2021
  2. snovikov commented on Jan 18, 2022

    @snovikov

    I have the same issue while using combination of github_actions_organization_secret and
    github_actions_organization_secret_repositories. When I use only github_actions_organization_secret - problem is gone.

  3. arbourd commented on Apr 30, 2022

    @arbourd

    We experienced this as well. github_actions_organization_secret_repositories is basically not functional if github_actions_organization_secret is used in tandem.

    The reason seems to be:

    • github_actions_organization_secret are created new every-time, if Terraform detects a difference
    • When you change (or add) github_actions_organization_secret_repositories or add selected repositories via the UI, it updates the github_actions_organization_secret
    • This causes a loop where the new secret will unset all the selected repository IDs, with ever apply.

    The solution to this is using the selected_repository_ids attribute in the github_actions_organization_secret itself. I'm not sure if this a bug or just something needs to be documented.

  4. github-actions commented on Jan 26, 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!

  5. added
    Status: Stale
    on Jan 26, 2023
  6. pylaligand commented on Jan 8, 2026

    @pylaligand

    FYI I am still observing a similar issue with github_codespaces_organization_secret and github_codespaces_organization_secret_repositories...

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: StaleType: Bugr/actions_secret

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions