Skip to content

Commit e0e458a

Browse files
committed
fix: destroy the resource on drift
closes 749
1 parent f7da074 commit e0e458a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

github/resource_github_actions_organization_secret.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ func resourceGithubActionsOrganizationSecret() *schema.Resource {
6969
Type: schema.TypeString,
7070
Computed: true,
7171
},
72+
"destroy_on_drift": {
73+
Type: schema.TypeBool,
74+
Optional: true,
75+
Default: true,
76+
},
7277
},
7378
}
7479
}
@@ -195,7 +200,8 @@ func resourceGithubActionsOrganizationSecretRead(d *schema.ResourceData, meta in
195200
// The only solution to enforce consistency between is to mark the resource
196201
// as deleted (unset the ID) in order to fix potential drift by recreating
197202
// the resource.
198-
if updatedAt, ok := d.GetOk("updated_at"); ok && updatedAt != secret.UpdatedAt.String() {
203+
destroyOnDrift := d.Get("destroy_on_drift").(bool)
204+
if updatedAt, ok := d.GetOk("updated_at"); ok && destroyOnDrift && updatedAt != secret.UpdatedAt.String() {
199205
log.Printf("[INFO] The secret %s has been externally updated in GitHub", d.Id())
200206
d.SetId("")
201207
} else if !ok {

0 commit comments

Comments
 (0)