diff --git a/mmv1/third_party/terraform/services/logging/resource_logging_project_sink.go b/mmv1/third_party/terraform/services/logging/resource_logging_project_sink.go index 86f28c26d76f..9a2ecf70d7d6 100644 --- a/mmv1/third_party/terraform/services/logging/resource_logging_project_sink.go +++ b/mmv1/third_party/terraform/services/logging/resource_logging_project_sink.go @@ -94,10 +94,19 @@ func resourceLoggingProjectSinkAcquireOrCreate(d *schema.ResourceData, meta inte return resourceLoggingProjectSinkUpdate(d, meta) } -// if bigquery_options is set unique_writer_identity must be true +// 1) if bigquery_options is set unique_writer_identity must be true +// 2) taint the value of writer_identity when unique_writer_identity is updating from false -> true func resourceLoggingProjectSinkCustomizeDiff(ctx context.Context, d *schema.ResourceDiff, meta interface{}) error { // separate func to allow unit testing - return resourceLoggingProjectSinkCustomizeDiffFunc(d) + err := resourceLoggingProjectSinkCustomizeDiffFunc(d) + if err != nil { + return err + } + err = resourceLoggingProjectSinkUniqueWriterIdentityCustomizeDiffFunc(d) + if err != nil { + return err + } + return nil } func resourceLoggingProjectSinkCustomizeDiffFunc(diff tpgresource.TerraformResourceDiff) error { @@ -115,6 +124,20 @@ func resourceLoggingProjectSinkCustomizeDiffFunc(diff tpgresource.TerraformResou return nil } +func resourceLoggingProjectSinkUniqueWriterIdentityCustomizeDiffFunc(diff *schema.ResourceDiff) error { + if !diff.HasChange("unique_writer_identity") { + return nil + } + // taint the value of writer_identity when unique_writer_identity is updating from false -> true + if diff.Get("unique_writer_identity").(bool) { + err := diff.SetNewComputed("writer_identity") + if err != nil { + return fmt.Errorf("Error re-setting writer_identity: %s", err) + } + } + return nil +} + func resourceLoggingProjectSinkRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent)