From f95d0173717f6755f9764d33f8d92bd148af393a Mon Sep 17 00:00:00 2001 From: The Magician Date: Tue, 13 Aug 2024 18:03:33 -0700 Subject: [PATCH] logging_project_bucket_config: support "no preference" for enable_analytics setting. (#11430) (#7964) [upstream:90589fba9e124d25ece290f144942815c267daf5] Signed-off-by: Modular Magician --- .changelog/11430.txt | 3 +++ .../logging/resource_logging_project_bucket_config.go | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 .changelog/11430.txt diff --git a/.changelog/11430.txt b/.changelog/11430.txt new file mode 100644 index 0000000000..a4e2d0f446 --- /dev/null +++ b/.changelog/11430.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +logging: changed enable_analytics parsing to "no preference" in analytics if omitted, instead of explicitly disabling analytics. +``` \ No newline at end of file diff --git a/google-beta/services/logging/resource_logging_project_bucket_config.go b/google-beta/services/logging/resource_logging_project_bucket_config.go index 432805caa0..31c2376cd4 100644 --- a/google-beta/services/logging/resource_logging_project_bucket_config.go +++ b/google-beta/services/logging/resource_logging_project_bucket_config.go @@ -189,7 +189,7 @@ func resourceLoggingProjectBucketConfigAcquireOrCreate(parentType string, iDFunc UserAgent: userAgent, }) if res == nil { - log.Printf("[DEGUG] Loggin Bucket not exist %s", id) + log.Printf("[DEBUG] Logging Bucket does not exist %s", id) // we need to pass the id in here because we don't want to set it in state // until we know there won't be any errors on create return resourceLoggingProjectBucketConfigCreate(d, meta, id) @@ -214,7 +214,11 @@ func resourceLoggingProjectBucketConfigCreate(d *schema.ResourceData, meta inter obj["description"] = d.Get("description") obj["locked"] = d.Get("locked") obj["retentionDays"] = d.Get("retention_days") - obj["analyticsEnabled"] = d.Get("enable_analytics") + // Only set analyticsEnabled if it has been explicitly preferenced. + analyticsRawValue := d.GetRawConfig().GetAttr("enable_analytics") + if !analyticsRawValue.IsNull() { + obj["analyticsEnabled"] = analyticsRawValue.True() + } obj["cmekSettings"] = expandCmekSettings(d.Get("cmek_settings")) obj["indexConfigs"] = expandIndexConfigs(d.Get("index_configs"))