diff --git a/modules/gke-cluster-autopilot/README.md b/modules/gke-cluster-autopilot/README.md index 8758bf177..281a15df4 100644 --- a/modules/gke-cluster-autopilot/README.md +++ b/modules/gke-cluster-autopilot/README.md @@ -91,28 +91,27 @@ module "cluster-1" { # tftest modules=1 resources=2 inventory=backup.yaml ``` - ## Variables | name | description | type | required | default | |---|---|:---:|:---:|:---:| -| [location](variables.tf#L110) | Autopilot cluster are always regional. | string | ✓ | | -| [name](variables.tf#L145) | Cluster name. | string | ✓ | | -| [project_id](variables.tf#L171) | Cluster project id. | string | ✓ | | -| [vpc_config](variables.tf#L194) | VPC-level configuration. | object({…}) | ✓ | | +| [location](variables.tf#L111) | Autopilot cluster are always regional. | string | ✓ | | +| [name](variables.tf#L146) | Cluster name. | string | ✓ | | +| [project_id](variables.tf#L172) | Cluster project id. | string | ✓ | | +| [vpc_config](variables.tf#L195) | VPC-level configuration. | object({…}) | ✓ | | | [backup_configs](variables.tf#L17) | Configuration for Backup for GKE. | object({…}) | | {} | | [description](variables.tf#L37) | Cluster description. | string | | null | | [enable_addons](variables.tf#L43) | Addons enabled in the cluster (true means enabled). | object({…}) | | {…} | -| [enable_features](variables.tf#L64) | Enable cluster-level features. Certain features allow configuration. | object({…}) | | {…} | -| [issue_client_certificate](variables.tf#L98) | Enable issuing client certificate. | bool | | false | -| [labels](variables.tf#L104) | Cluster resource labels. | map(string) | | null | -| [maintenance_config](variables.tf#L116) | Maintenance window configuration. | object({…}) | | {…} | -| [min_master_version](variables.tf#L139) | Minimum version of the master, defaults to the version of the most recent official release. | string | | null | -| [node_locations](variables.tf#L150) | Zones in which the cluster's nodes are located. | list(string) | | [] | -| [private_cluster_config](variables.tf#L157) | Private cluster configuration. | object({…}) | | null | -| [release_channel](variables.tf#L176) | Release channel for GKE upgrades. | string | | null | -| [service_account](variables.tf#L182) | The Google Cloud Platform Service Account to be used by the node VMs created by GKE Autopilot. | string | | null | -| [tags](variables.tf#L188) | Network tags applied to nodes. | list(string) | | null | +| [enable_features](variables.tf#L64) | Enable cluster-level features. Certain features allow configuration. | object({…}) | | {…} | +| [issue_client_certificate](variables.tf#L99) | Enable issuing client certificate. | bool | | false | +| [labels](variables.tf#L105) | Cluster resource labels. | map(string) | | null | +| [maintenance_config](variables.tf#L117) | Maintenance window configuration. | object({…}) | | {…} | +| [min_master_version](variables.tf#L140) | Minimum version of the master, defaults to the version of the most recent official release. | string | | null | +| [node_locations](variables.tf#L151) | Zones in which the cluster's nodes are located. | list(string) | | [] | +| [private_cluster_config](variables.tf#L158) | Private cluster configuration. | object({…}) | | null | +| [release_channel](variables.tf#L177) | Release channel for GKE upgrades. | string | | null | +| [service_account](variables.tf#L183) | The Google Cloud Platform Service Account to be used by the node VMs created by GKE Autopilot. | string | | null | +| [tags](variables.tf#L189) | Network tags applied to nodes. | list(string) | | null | ## Outputs @@ -128,5 +127,4 @@ module "cluster-1" { | [notifications](outputs.tf#L54) | GKE PubSub notifications topic. | | | [self_link](outputs.tf#L59) | Cluster self link. | ✓ | | [workload_identity_pool](outputs.tf#L65) | Workload identity pool. | | - diff --git a/modules/gke-cluster-autopilot/main.tf b/modules/gke-cluster-autopilot/main.tf index 4b18f3ad6..7b51b56a6 100644 --- a/modules/gke-cluster-autopilot/main.tf +++ b/modules/gke-cluster-autopilot/main.tf @@ -69,6 +69,13 @@ resource "google_container_cluster" "cluster" { } } + dynamic "cost_management_config" { + for_each = var.enable_features.cost_management == true ? [""] : [] + content { + enabled = true + } + } + cluster_autoscaling { dynamic "auto_provisioning_defaults" { for_each = var.service_account != null ? [""] : [] diff --git a/modules/gke-cluster-autopilot/variables.tf b/modules/gke-cluster-autopilot/variables.tf index 5965cb64c..60350366c 100644 --- a/modules/gke-cluster-autopilot/variables.tf +++ b/modules/gke-cluster-autopilot/variables.tf @@ -65,6 +65,7 @@ variable "enable_features" { description = "Enable cluster-level features. Certain features allow configuration." type = object({ binary_authorization = optional(bool, false) + cost_management = optional(bool, false) dns = optional(object({ provider = optional(string) scope = optional(string) diff --git a/modules/gke-cluster-standard/README.md b/modules/gke-cluster-standard/README.md index a971d5ead..40548f620 100644 --- a/modules/gke-cluster-standard/README.md +++ b/modules/gke-cluster-standard/README.md @@ -126,31 +126,30 @@ module "cluster-1" { # tftest modules=1 resources=2 inventory=backup.yaml ``` - ## Variables | name | description | type | required | default | |---|---|:---:|:---:|:---:| -| [location](variables.tf#L137) | Cluster zone or region. | string | ✓ | | -| [name](variables.tf#L194) | Cluster name. | string | ✓ | | -| [project_id](variables.tf#L220) | Cluster project id. | string | ✓ | | -| [vpc_config](variables.tf#L237) | VPC-level configuration. | object({…}) | ✓ | | +| [location](variables.tf#L138) | Cluster zone or region. | string | ✓ | | +| [name](variables.tf#L195) | Cluster name. | string | ✓ | | +| [project_id](variables.tf#L221) | Cluster project id. | string | ✓ | | +| [vpc_config](variables.tf#L238) | VPC-level configuration. | object({…}) | ✓ | | | [backup_configs](variables.tf#L17) | Configuration for Backup for GKE. | object({…}) | | {} | | [cluster_autoscaling](variables.tf#L37) | Enable and configure limits for Node Auto-Provisioning with Cluster Autoscaler. | object({…}) | | null | | [description](variables.tf#L58) | Cluster description. | string | | null | | [enable_addons](variables.tf#L64) | Addons enabled in the cluster (true means enabled). | object({…}) | | {…} | -| [enable_features](variables.tf#L87) | Enable cluster-level features. Certain features allow configuration. | object({…}) | | {…} | -| [issue_client_certificate](variables.tf#L125) | Enable issuing client certificate. | bool | | false | -| [labels](variables.tf#L131) | Cluster resource labels. | map(string) | | null | -| [logging_config](variables.tf#L142) | Logging configuration. | list(string) | | ["SYSTEM_COMPONENTS"] | -| [maintenance_config](variables.tf#L148) | Maintenance window configuration. | object({…}) | | {…} | -| [max_pods_per_node](variables.tf#L171) | Maximum number of pods per node in this cluster. | number | | 110 | -| [min_master_version](variables.tf#L177) | Minimum version of the master, defaults to the version of the most recent official release. | string | | null | -| [monitoring_config](variables.tf#L183) | Monitoring components. | object({…}) | | {…} | -| [node_locations](variables.tf#L199) | Zones in which the cluster's nodes are located. | list(string) | | [] | -| [private_cluster_config](variables.tf#L206) | Private cluster configuration. | object({…}) | | null | -| [release_channel](variables.tf#L225) | Release channel for GKE upgrades. | string | | null | -| [tags](variables.tf#L231) | Network tags applied to nodes. | list(string) | | null | +| [enable_features](variables.tf#L87) | Enable cluster-level features. Certain features allow configuration. | object({…}) | | {…} | +| [issue_client_certificate](variables.tf#L126) | Enable issuing client certificate. | bool | | false | +| [labels](variables.tf#L132) | Cluster resource labels. | map(string) | | null | +| [logging_config](variables.tf#L143) | Logging configuration. | list(string) | | ["SYSTEM_COMPONENTS"] | +| [maintenance_config](variables.tf#L149) | Maintenance window configuration. | object({…}) | | {…} | +| [max_pods_per_node](variables.tf#L172) | Maximum number of pods per node in this cluster. | number | | 110 | +| [min_master_version](variables.tf#L178) | Minimum version of the master, defaults to the version of the most recent official release. | string | | null | +| [monitoring_config](variables.tf#L184) | Monitoring components. | object({…}) | | {…} | +| [node_locations](variables.tf#L200) | Zones in which the cluster's nodes are located. | list(string) | | [] | +| [private_cluster_config](variables.tf#L207) | Private cluster configuration. | object({…}) | | null | +| [release_channel](variables.tf#L226) | Release channel for GKE upgrades. | string | | null | +| [tags](variables.tf#L232) | Network tags applied to nodes. | list(string) | | null | ## Outputs @@ -166,5 +165,4 @@ module "cluster-1" { | [notifications](outputs.tf#L54) | GKE PubSub notifications topic. | | | [self_link](outputs.tf#L59) | Cluster self link. | ✓ | | [workload_identity_pool](outputs.tf#L65) | Workload identity pool. | | - diff --git a/modules/gke-cluster-standard/main.tf b/modules/gke-cluster-standard/main.tf index 9c0518358..bbf0d1061 100644 --- a/modules/gke-cluster-standard/main.tf +++ b/modules/gke-cluster-standard/main.tf @@ -106,6 +106,13 @@ resource "google_container_cluster" "cluster" { } } + dynamic "cost_management_config" { + for_each = var.enable_features.cost_management == true ? [""] : [] + content { + enabled = true + } + } + dynamic "cluster_autoscaling" { for_each = var.cluster_autoscaling == null ? [] : [""] content { diff --git a/modules/gke-cluster-standard/variables.tf b/modules/gke-cluster-standard/variables.tf index cced31298..15bce4691 100644 --- a/modules/gke-cluster-standard/variables.tf +++ b/modules/gke-cluster-standard/variables.tf @@ -88,6 +88,7 @@ variable "enable_features" { description = "Enable cluster-level features. Certain features allow configuration." type = object({ binary_authorization = optional(bool, false) + cost_management = optional(bool, false) dns = optional(object({ provider = optional(string) scope = optional(string)