diff --git a/mmv1/third_party/terraform/services/container/resource_container_cluster.go.tmpl b/mmv1/third_party/terraform/services/container/resource_container_cluster.go.tmpl
index ab045da4f80b..9cdb2dce0f84 100644
--- a/mmv1/third_party/terraform/services/container/resource_container_cluster.go.tmpl
+++ b/mmv1/third_party/terraform/services/container/resource_container_cluster.go.tmpl
@@ -1273,6 +1273,25 @@ func ResourceContainerCluster() *schema.Resource {
Required: true,
Description: `Whether or not the managed collection is enabled.`,
},
+ {{- if ne $.TargetVersionName "ga" }}
+ "auto_monitoring_config": {
+ Type: schema.TypeList,
+ Optional: true,
+ Computed: true,
+ MaxItems: 1,
+ Description: `Configuration for GKE Workload Auto-Monitoring.`,
+ Elem: &schema.Resource{
+ Schema: map[string]*schema.Schema{
+ "scope": {
+ Type: schema.TypeString,
+ Required: true,
+ Description: `The scope of auto-monitoring.`,
+ ValidateFunc: validation.StringInSlice([]string{"ALL", "NONE"}, false),
+ },
+ },
+ },
+ },
+ {{- end }}
},
},
},
@@ -5894,6 +5913,20 @@ func expandMonitoringConfig(configured interface{}) *container.MonitoringConfig
mc.ManagedPrometheusConfig = &container.ManagedPrometheusConfig{
Enabled: managed_prometheus["enabled"].(bool),
}
+ {{- if ne $.TargetVersionName "ga" }}
+ if autoMonitoring, ok := managed_prometheus["auto_monitoring_config"]; ok {
+ if autoMonitoringList, ok := autoMonitoring.([]interface{}); ok {
+ if len(autoMonitoringList) > 0 {
+ autoMonitoringConfig := autoMonitoringList[0].(map[string]interface{})
+ if scope, ok := autoMonitoringConfig["scope"].(string); ok && scope != "" {
+ mc.ManagedPrometheusConfig.AutoMonitoringConfig = &container.AutoMonitoringConfig{
+ Scope: scope,
+ }
+ }
+ }
+ }
+ }
+ {{- end }}
}
if v, ok := config["advanced_datapath_observability_config"]; ok && len(v.([]interface{})) > 0 {
@@ -6871,11 +6904,26 @@ func flattenAdvancedDatapathObservabilityConfig(c *container.AdvancedDatapathObs
}
func flattenManagedPrometheusConfig(c *container.ManagedPrometheusConfig) []map[string]interface{} {
- return []map[string]interface{}{
- {
- "enabled": c != nil && c.Enabled,
- },
- }
+ if c == nil {
+ return nil
+ }
+
+ result := make(map[string]interface{})
+ result["enabled"] = c.Enabled
+
+ {{- if ne $.TargetVersionName "ga" }}
+ autoMonitoringList := []map[string]interface{}{}
+ if c.AutoMonitoringConfig != nil && c.AutoMonitoringConfig.Scope != "" {
+ autoMonitoringMap := map[string]interface{}{
+ "scope": c.AutoMonitoringConfig.Scope,
+ }
+ autoMonitoringList = append(autoMonitoringList, autoMonitoringMap)
+ }
+
+ result["auto_monitoring_config"] = autoMonitoringList
+ {{- end }}
+
+ return []map[string]interface{}{result}
}
func flattenNodePoolAutoConfig(c *container.NodePoolAutoConfig) []map[string]interface{} {
diff --git a/mmv1/third_party/terraform/services/container/resource_container_cluster_test.go.tmpl b/mmv1/third_party/terraform/services/container/resource_container_cluster_test.go.tmpl
index ef6ca08968ca..55355d144468 100644
--- a/mmv1/third_party/terraform/services/container/resource_container_cluster_test.go.tmpl
+++ b/mmv1/third_party/terraform/services/container/resource_container_cluster_test.go.tmpl
@@ -3966,6 +3966,32 @@ func TestAccContainerCluster_withMonitoringConfig(t *testing.T) {
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"min_master_version", "deletion_protection"},
},
+ {{- if ne $.TargetVersionName "ga" }}
+ {
+ Config: testAccContainerCluster_withMonitoringConfigScopeAll(clusterName, networkName, subnetworkName),
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("google_container_cluster.primary", "monitoring_config.0.managed_prometheus.0.auto_monitoring_config.0.scope", "ALL"),
+ ),
+ },
+ {
+ ResourceName: "google_container_cluster.primary",
+ ImportState: true,
+ ImportStateVerify: true,
+ ImportStateVerifyIgnore: []string{"min_master_version", "deletion_protection"},
+ },
+ {
+ Config: testAccContainerCluster_withMonitoringConfigScopeNone(clusterName, networkName, subnetworkName),
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("google_container_cluster.primary", "monitoring_config.0.managed_prometheus.0.auto_monitoring_config.0.scope", "NONE"),
+ ),
+ },
+ {
+ ResourceName: "google_container_cluster.primary",
+ ImportState: true,
+ ImportStateVerify: true,
+ ImportStateVerifyIgnore: []string{"min_master_version", "deletion_protection"},
+ },
+ {{- end }}
// Back to basic settings to test setting Prometheus on its own
{
Config: testAccContainerCluster_basic(clusterName, networkName, subnetworkName),
@@ -10786,6 +10812,50 @@ resource "google_container_cluster" "primary" {
`, name, networkName, subnetworkName)
}
+{{- if ne $.TargetVersionName "ga" }}
+func testAccContainerCluster_withMonitoringConfigScopeAll(name, networkName, subnetworkName 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
+ auto_monitoring_config {
+ scope = "ALL"
+ }
+ }
+ }
+ deletion_protection = false
+ network = "%s"
+ subnetwork = "%s"
+}
+`, name, networkName, subnetworkName)
+}
+
+func testAccContainerCluster_withMonitoringConfigScopeNone(name, networkName, subnetworkName 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
+ auto_monitoring_config {
+ scope = "NONE"
+ }
+ }
+ }
+ deletion_protection = false
+ network = "%s"
+ subnetwork = "%s"
+}
+`, name, networkName, subnetworkName)
+}
+{{- end }}
+
func testAccContainerCluster_withMonitoringConfigAdvancedDatapathObservabilityConfigEnabled(name string) string {
return fmt.Sprintf(`
resource "google_compute_network" "container_network" {
diff --git a/mmv1/third_party/terraform/website/docs/r/container_cluster.html.markdown b/mmv1/third_party/terraform/website/docs/r/container_cluster.html.markdown
index b69680f24eca..c9d621e470ea 100644
--- a/mmv1/third_party/terraform/website/docs/r/container_cluster.html.markdown
+++ b/mmv1/third_party/terraform/website/docs/r/container_cluster.html.markdown
@@ -663,6 +663,11 @@ This block also contains several computed attributes, documented below.
The `managed_prometheus` block supports:
* `enabled` - (Required) Whether or not the managed collection is enabled.
+* `auto_monitoring_config` - (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)) Configuration options for GKE Auto-Monitoring.
+
+The `auto_monitoring_config` block supports:
+
+* `scope` - (Required) Whether or not to enable GKE Auto-Monitoring. Supported values include: `ALL`, `NONE`.
The `advanced_datapath_observability_config` block supports: