Skip to content

[BUG]: github_actions_organization_secret secret recreated after manual update #1383

Closed as not planned

Description

@johankees

Terraform Version

Run terraform -v to show the version. If you are not running the latest version of Terraform, please upgrade because your issue may have already been fixed.

terraform -v
Terraform v1.3.5
on linux_amd64
+ provider registry.terraform.io/integrations/github v5.9.1

Affected Resource(s)

  • github_actions_organization_secret

Terraform Configuration Files

resource "github_actions_organization_secret" "secret" {
  secret_name = "TEST_SECRET"
  visibility  = "private"

  lifecycle {
    ignore_changes = [
      plaintext_value,
      encrypted_value
    ]
  }
}

Debug Output

State file

{
  "version": 4,
  "terraform_version": "1.3.5",
  "serial": 20,
  "lineage": "f6210cb1-a789-4343-822c-60148393fdc3",
  "outputs": {},
  "resources": [
    {
      "mode": "managed",
      "type": "github_actions_organization_secret",
      "name": "admin-token",
      "provider": "provider[\"registry.terraform.io/integrations/github\"]",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "created_at": "2022-11-23 10:47:28 +0000 UTC",
            "encrypted_value": "",
            "id": "TEST_SECRET",
            "plaintext_value": "",
            "secret_name": "TEST_SECRET",
            "selected_repository_ids": null,
            "updated_at": "2022-11-23 10:47:53 +0000 UTC",
            "visibility": "private"
          },
          "sensitive_attributes": [],
          "private": "bnVsbA=="
        }
      ]
    }
  ],
  "check_results": null
}

Panic Output

N/A

Expected Behavior

The secret should not be recreated nor updated. I.e. terraform runs should be idempotent.

Actual Behavior

The secret gets recreated resetting the value of the secret to an empty string.

It looks like the id gets changed when the value was manually set in GitHub, hence the provider lost track of the resource. The state file does have the correct information. (see Debug output)

The linked issue (#974) mentions the use of ignore_changes lifecycle. This doesn't resolve the issue. Tested by adding updated_at, but this field is ignored.

Steps to Reproduce

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

  1. terraform apply
  2. make manual update in GitHub to set the value
  3. terraform apply

Important Factoids

N/A

References

Activity

  1. changed the title [-][BUG] `github_actions_organization_secret` secret recreated after manual update[/-] [+][BUG]: `github_actions_organization_secret` secret recreated after manual update[/+] on Nov 23, 2022
  2. added
    Type: Bug
    Status: Up for grabs
    on Nov 28, 2022
  3. wadells commented on Apr 7, 2023

    @wadells

    I've also encountered this same behavior with github_actions_environment_secret.

    resource "github_actions_environment_secret" "placeholder" {
      repository      = "test"
      environment     = "test"
      secret_name     = "TEST"
      plaintext_value = "" # placeholder value, secrets mgmt not implemented yet
    
      lifecycle {
        ignore_changes = [ 
          plaintext_value
        ]   
      }
    }

    After the secret is created, I edit it by hand to put a value in place. However, upon the next terraform run the secret is recreated with an empty value.

  4. aandac commented on Jun 9, 2023

    @aandac

    +1

  5. kwantopia commented on Jun 10, 2023

    @kwantopia

    Yes please help fix!

  6. casonlassomd commented on Jun 12, 2023

    @casonlassomd

    Please help to fix. Looking forward.

  7. GabrielFerrarini commented on Jun 14, 2023

    @GabrielFerrarini

    Even selecting all won't work (using the same example from @wadells

    resource "github_actions_environment_secret" "placeholder" {
      repository      = "test"
      environment     = "test"
      secret_name     = "TEST"
      plaintext_value = "" # placeholder value, secrets mgmt not implemented yet
    
      lifecycle {
        ignore_changes = all   
      }
    
  8. kfcampbell commented on Jun 20, 2023

    @kfcampbell
    Contributor

    It looks like in cases of both creating and updating, we call CreateOrUpdateOrgSecret which routes to this API reference.

    Is the suggestion that the provider avoids making this call in some scenarios on updating?

  9. GabrielFerrarini commented on Jun 26, 2023

    @GabrielFerrarini

    @kfcampbell
    In the particular scenario where the below is set, because we're explicitly asking terraform to not update these secrets.

      lifecycle {
        ignore_changes = all   
      }
    

    or

      lifecycle {
        ignore_changes = [ 
          plaintext_value
        ]   
      }
    

    or

      lifecycle {
        ignore_changes = [ 
          encrypted_value
        ]   
      }
    

    or similar

  10. GabrielFerrarini commented on Aug 27, 2023

    @GabrielFerrarini

    @kfcampbell @nickfloyd
    Any ideas if this is going to be worked on soon?

  11. kfcampbell commented on Sep 5, 2023

    @kfcampbell
    Contributor

    @GabrielFerrarini unfortunately GitHub's SDK team generally doesn't have the bandwidth to work on this type of issue directly. Do you have the interest or inclination to open up a PR for this behavior?

  12. vparmeland commented on Apr 15, 2024

    @vparmeland

    Any news ??

  13. nbali commented on Nov 13, 2024

    @nbali

    So this is the logic that is responsible for this behaviour:

    	if updatedAt, ok := d.GetOk("updated_at"); ok && updatedAt != secret.UpdatedAt.String() {
    		log.Printf("[INFO] The secret %s has been externally updated in GitHub", d.Id())
    		d.SetId("")
    	} else if !ok {
    		if err = d.Set("updated_at", secret.UpdatedAt.String()); err != nil {
    			return err
    		}
    	}

    Wouldn't this solve our issue, but keep the original functionality as well?

    	if updatedAt, ok := d.GetOk("updated_at"); ok && updatedAt != secret.UpdatedAt.String() {
    		log.Printf("[INFO] The secret %s has been externally updated in GitHub", d.Id())
    		d.Set("encrypted_value", "")
    		d.Set("plaintext_value", "")
    	} else if !ok {
    		if err = d.Set("updated_at", secret.UpdatedAt.String()); err != nil {
    			return err
    		}
    	}
  14. jorgecarleitao commented on Dec 5, 2024

    @jorgecarleitao

    @nbali, I PRed your suggestion; @kfcampbell, I got interest.

  15. github-actions commented on Sep 2, 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!

  16. added
    Status: Stale
    on Sep 2, 2025
  17. nbali commented on Sep 26, 2025

    @nbali

    Not stale at all.

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: StaleStatus: Up for grabsType: Bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions