From 01b59d9bfdedbb24789e159fb13478ec5eeaa998 Mon Sep 17 00:00:00 2001 From: Edward Sun Date: Mon, 10 Jul 2023 09:02:41 -0700 Subject: [PATCH 1/2] make monitoring_config enable_components optional --- .../resource_container_cluster.go.erb | 7 +++--- .../resource_container_cluster_test.go.erb | 23 +++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/mmv1/third_party/terraform/services/container/resource_container_cluster.go.erb b/mmv1/third_party/terraform/services/container/resource_container_cluster.go.erb index f46444945d0b..0484dffa780b 100644 --- a/mmv1/third_party/terraform/services/container/resource_container_cluster.go.erb +++ b/mmv1/third_party/terraform/services/container/resource_container_cluster.go.erb @@ -920,7 +920,7 @@ func ResourceContainerCluster() *schema.Resource { Schema: map[string]*schema.Schema{ "enable_components": { Type: schema.TypeList, - Required: true, + Optional: true, Description: `GKE components exposing logs. Valid values include SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS.`, Elem: &schema.Schema{ Type: schema.TypeString, @@ -1127,12 +1127,11 @@ func ResourceContainerCluster() *schema.Resource { Schema: map[string]*schema.Schema{ "enable_components": { Type: schema.TypeList, + Optional: true, + Computed: true, <% if version == "ga" -%> - Required: true, Description: `GKE components exposing metrics. Valid values include SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, and SCHEDULER.`, <% else -%> - Optional: true, - Computed: true, Description: `GKE components exposing metrics. Valid values include SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS.`, <% end -%> Elem: &schema.Schema{ diff --git a/mmv1/third_party/terraform/tests/resource_container_cluster_test.go.erb b/mmv1/third_party/terraform/tests/resource_container_cluster_test.go.erb index 36aa886a4066..3ed25346a93e 100644 --- a/mmv1/third_party/terraform/tests/resource_container_cluster_test.go.erb +++ b/mmv1/third_party/terraform/tests/resource_container_cluster_test.go.erb @@ -2693,6 +2693,15 @@ func TestAccContainerCluster_withMonitoringConfig(t *testing.T) { ImportStateVerify: true, ImportStateVerifyIgnore: []string{"min_master_version"}, }, + { + Config: testAccContainerCluster_withMonitoringConfigPrometheusOnly2(clusterName), + }, + { + ResourceName: "google_container_cluster.primary", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"min_master_version"}, + }, { Config: testAccContainerCluster_basic(clusterName), }, @@ -7451,6 +7460,20 @@ resource "google_container_cluster" "primary" { `, name) } +func testAccContainerCluster_withMonitoringConfigPrometheusOnly2(name string) string { + return fmt.Sprintf(` +resource "google_container_cluster" "primary" { + name = "%s" + location = "us-central1-a" + initial_node_count = 1 + monitoring_config { + managed_prometheus { + enabled = true + } + } +} +`, name) +} func testAccContainerCluster_withSoleTenantGroup(name string) string { return fmt.Sprintf(` From 7152cd4fc2bc1065975b6d7e97c0075d5f24193d Mon Sep 17 00:00:00 2001 From: Edward Sun Date: Mon, 10 Jul 2023 15:46:55 -0700 Subject: [PATCH 2/2] set no change on logging_config.enable_components --- .../services/container/resource_container_cluster.go.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmv1/third_party/terraform/services/container/resource_container_cluster.go.erb b/mmv1/third_party/terraform/services/container/resource_container_cluster.go.erb index 0484dffa780b..366d559ae162 100644 --- a/mmv1/third_party/terraform/services/container/resource_container_cluster.go.erb +++ b/mmv1/third_party/terraform/services/container/resource_container_cluster.go.erb @@ -920,7 +920,7 @@ func ResourceContainerCluster() *schema.Resource { Schema: map[string]*schema.Schema{ "enable_components": { Type: schema.TypeList, - Optional: true, + Required: true, Description: `GKE components exposing logs. Valid values include SYSTEM_COMPONENTS, APISERVER, CONTROLLER_MANAGER, SCHEDULER, and WORKLOADS.`, Elem: &schema.Schema{ Type: schema.TypeString,