diff --git a/.changelog/5648.txt b/.changelog/5648.txt new file mode 100644 index 00000000000..b574112e0aa --- /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/resource_container_cluster.go b/google/resource_container_cluster.go index f27bf16f93c..2e95f2628a8 100644 --- a/google/resource_container_cluster.go +++ b/google/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", } forceNewClusterNodeConfigFields = []string{ @@ -228,6 +229,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, @@ -2564,6 +2582,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{ @@ -3068,6 +3094,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/resource_container_cluster_test.go b/google/resource_container_cluster_test.go index 61bd894b2e6..ce8b4143048 100644 --- a/google/resource_container_cluster_test.go +++ b/google/resource_container_cluster_test.go @@ -2095,6 +2095,9 @@ resource "google_container_cluster" "primary" { network_policy_config { disabled = true } + gcp_filestore_csi_driver_config { + enabled = false + } cloudrun_config { disabled = true } @@ -2130,6 +2133,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 6074be49083..d2a53ceaaea 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)).