diff --git a/.changelog/6898.txt b/.changelog/6898.txt new file mode 100644 index 00000000000..292ddfecec0 --- /dev/null +++ b/.changelog/6898.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +container: promoted `gke_backup_agent_config` in `google_container_cluster` to GA +``` diff --git a/google/resource_container_cluster.go b/google/resource_container_cluster.go index d249c737f82..5913dbc6904 100644 --- a/google/resource_container_cluster.go +++ b/google/resource_container_cluster.go @@ -68,6 +68,7 @@ var ( "addons_config.0.gcp_filestore_csi_driver_config", "addons_config.0.dns_cache_config", "addons_config.0.gce_persistent_disk_csi_driver_config", + "addons_config.0.gke_backup_agent_config", } privateClusterConfigKeys = []string{ @@ -366,6 +367,22 @@ func resourceContainerCluster() *schema.Resource { }, }, }, + "gke_backup_agent_config": { + Type: schema.TypeList, + Optional: true, + Computed: true, + AtLeastOneOf: addonsConfigKeys, + MaxItems: 1, + Description: `The status of the Backup for GKE Agent addon. It is disabled by default. Set enabled = true to enable.`, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "enabled": { + Type: schema.TypeBool, + Required: true, + }, + }, + }, + }, }, }, }, @@ -3357,6 +3374,13 @@ func expandClusterAddonsConfig(configured interface{}) *container.AddonsConfig { ForceSendFields: []string{"Enabled"}, } } + if v, ok := config["gke_backup_agent_config"]; ok && len(v.([]interface{})) > 0 { + addon := v.([]interface{})[0].(map[string]interface{}) + ac.GkeBackupAgentConfig = &container.GkeBackupAgentConfig{ + Enabled: addon["enabled"].(bool), + ForceSendFields: []string{"Enabled"}, + } + } return ac } @@ -4205,6 +4229,13 @@ func flattenClusterAddonsConfig(c *container.AddonsConfig) []map[string]interfac }, } } + if c.GkeBackupAgentConfig != nil { + result["gke_backup_agent_config"] = []map[string]interface{}{ + { + "enabled": c.GkeBackupAgentConfig.Enabled, + }, + } + } return []map[string]interface{}{result} } diff --git a/google/resource_container_cluster_test.go b/google/resource_container_cluster_test.go index 4a979d57f22..4b3ab79a1ce 100644 --- a/google/resource_container_cluster_test.go +++ b/google/resource_container_cluster_test.go @@ -3166,6 +3166,9 @@ resource "google_container_cluster" "primary" { gce_persistent_disk_csi_driver_config { enabled = false } + gke_backup_agent_config { + enabled = false + } } } `, projectID, clusterName) @@ -3212,6 +3215,9 @@ resource "google_container_cluster" "primary" { gce_persistent_disk_csi_driver_config { enabled = true } + gke_backup_agent_config { + enabled = true + } } } `, projectID, clusterName) diff --git a/google/validation_test.go b/google/validation_test.go index bfae089ce9a..530a2075c4d 100644 --- a/google/validation_test.go +++ b/google/validation_test.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) -func TestvalidateGCEName(t *testing.T) { +func TestValidateGCEName(t *testing.T) { x := []StringValidationTestCase{ // No errors {TestName: "basic", Value: "foobar"}, diff --git a/website/docs/r/container_cluster.html.markdown b/website/docs/r/container_cluster.html.markdown index 82774661248..5b99834346b 100644 --- a/website/docs/r/container_cluster.html.markdown +++ b/website/docs/r/container_cluster.html.markdown @@ -403,14 +403,15 @@ subnetwork in which the cluster's instances are launched. * `gce_persistent_disk_csi_driver_config` - (Optional). Whether this cluster should enable the Google Compute Engine Persistent Disk Container Storage Interface (CSI) Driver. Defaults to disabled; set `enabled = true` to enabled. +* `gke_backup_agent_config` - (Optional). + The status of the Backup for GKE agent addon. It is disabled by default; Set `enabled = true` to enable. + * `kalm_config` - (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)). Configuration for the KALM addon, which manages the lifecycle of k8s. It is disabled by default; Set `enabled = true` to enable. * `config_connector_config` - (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)). The status of the ConfigConnector addon. It is disabled by default; Set `enabled = true` to enable. -* `gke_backup_agent_config` - (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)). - The status of the Backup for GKE agent addon. It is disabled by default; Set `enabled = true` to enable. This example `addons_config` disables two addons: