diff --git a/.changelog/5648.txt b/.changelog/5648.txt new file mode 100644 index 0000000000..b574112e0a --- /dev/null +++ b/.changelog/5648.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +container: added support for GCPFilestoreCSIDriver addon to `google_container_cluster` resource. +``` diff --git a/google-beta/resource_container_cluster.go b/google-beta/resource_container_cluster.go index 3a05f48d5b..64caf3f25e 100644 --- a/google-beta/resource_container_cluster.go +++ b/google-beta/resource_container_cluster.go @@ -59,6 +59,7 @@ var ( "addons_config.0.horizontal_pod_autoscaling", "addons_config.0.network_policy_config", "addons_config.0.cloudrun_config", + "addons_config.0.gcp_filestore_csi_driver_config", "addons_config.0.istio_config", "addons_config.0.dns_cache_config", "addons_config.0.gce_persistent_disk_csi_driver_config", @@ -248,6 +249,23 @@ func resourceContainerCluster() *schema.Resource { }, }, }, + "gcp_filestore_csi_driver_config": { + Type: schema.TypeList, + Optional: true, + Computed: true, + AtLeastOneOf: addonsConfigKeys, + MaxItems: 1, + Description: `The status of the Filestore CSI driver addon, which allows the usage of filestore instance as volumes. Defaults to disabled; set enabled = true to enable.`, + ConflictsWith: []string{"enable_autopilot"}, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "enabled": { + Type: schema.TypeBool, + Required: true, + }, + }, + }, + }, "cloudrun_config": { Type: schema.TypeList, Optional: true, @@ -2957,6 +2975,14 @@ func expandClusterAddonsConfig(configured interface{}) *container.AddonsConfig { } } + if v, ok := config["gcp_filestore_csi_driver_config"]; ok && len(v.([]interface{})) > 0 { + addon := v.([]interface{})[0].(map[string]interface{}) + ac.GcpFilestoreCsiDriverConfig = &container.GcpFilestoreCsiDriverConfig{ + Enabled: addon["enabled"].(bool), + ForceSendFields: []string{"Enabled"}, + } + } + if v, ok := config["cloudrun_config"]; ok && len(v.([]interface{})) > 0 { addon := v.([]interface{})[0].(map[string]interface{}) ac.CloudRunConfig = &container.CloudRunConfig{ @@ -3590,6 +3616,14 @@ func flattenClusterAddonsConfig(c *container.AddonsConfig) []map[string]interfac } } + if c.GcpFilestoreCsiDriverConfig != nil { + result["gcp_filestore_csi_driver_config"] = []map[string]interface{}{ + { + "enabled": c.GcpFilestoreCsiDriverConfig.Enabled, + }, + } + } + if c.CloudRunConfig != nil { cloudRunConfig := map[string]interface{}{ "disabled": c.CloudRunConfig.Disabled, diff --git a/google-beta/resource_container_cluster_test.go b/google-beta/resource_container_cluster_test.go index 7cc3e13573..371af9b827 100644 --- a/google-beta/resource_container_cluster_test.go +++ b/google-beta/resource_container_cluster_test.go @@ -2519,6 +2519,9 @@ resource "google_container_cluster" "primary" { network_policy_config { disabled = true } + gcp_filestore_csi_driver_config { + enabled = false + } cloudrun_config { disabled = true } @@ -2570,6 +2573,9 @@ resource "google_container_cluster" "primary" { network_policy_config { disabled = false } + gcp_filestore_csi_driver_config { + enabled = true + } cloudrun_config { disabled = false } diff --git a/website/docs/r/container_cluster.html.markdown b/website/docs/r/container_cluster.html.markdown index 6074be4908..d2a53ceaae 100644 --- a/website/docs/r/container_cluster.html.markdown +++ b/website/docs/r/container_cluster.html.markdown @@ -367,6 +367,10 @@ subnetwork in which the cluster's instances are launched. It can only be disabled if the nodes already do not have network policies enabled. Defaults to disabled; set `disabled = false` to enable. +* `gcp_filestore_csi_driver_config` - (Optional) The status of the Filestore CSI driver addon, + which allows the usage of filestore instance as volumes. + It is disbaled by default; set `enabled = true` to enable. + * `cloudrun_config` - (Optional). Structure is [documented below](#nested_cloudrun_config). * `istio_config` - (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)).