Skip to content

Commit 10ea608

Browse files
authored
feat!: cost_management_config is out of beta now (terraform-google-modules#1470)
feat: cost_management_config is out of beta now move the config outside the logic of beta only Co-authored-by: Zackary Maupin <zackary.maupin@wunderkind.co>
1 parent f57f3ce commit 10ea608

File tree

24 files changed

+48
-27
lines changed

24 files changed

+48
-27
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ Then perform the following commands on the root folder:
147147
| disable\_legacy\_metadata\_endpoints | Disable the /0.1/ and /v1beta1/ metadata server endpoints on the node. Changing this value will cause all node pools to be recreated. | `bool` | `true` | no |
148148
| dns\_cache | The status of the NodeLocal DNSCache addon. | `bool` | `false` | no |
149149
| enable\_binary\_authorization | Enable BinAuthZ Admission controller | `bool` | `false` | no |
150+
| enable\_cost\_allocation | Enables Cost Allocation Feature and the cluster name and namespace of your GKE workloads appear in the labels field of the billing export to BigQuery | `bool` | `false` | no |
150151
| enable\_network\_egress\_export | Whether to enable network egress metering for this cluster. If enabled, a daemonset will be created in the cluster to meter network egress traffic. | `bool` | `false` | no |
151152
| enable\_resource\_consumption\_export | Whether to enable resource consumption metering on this cluster. When enabled, a table will be created in the resource export BigQuery dataset to store resource consumption data. The resulting table can be joined with the resource usage table or with BigQuery billing export. | `bool` | `true` | no |
152153
| enable\_shielded\_nodes | Enable Shielded Nodes features on all nodes in this cluster | `bool` | `true` | no |

autogen/main/cluster.tf.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ resource "google_container_cluster" "primary" {
5353
channel = release_channel.value.channel
5454
}
5555
}
56-
{% if beta_cluster %}
5756
dynamic "cost_management_config" {
5857
for_each = var.enable_cost_allocation ? [1] : []
5958
content {
6059
enabled = var.enable_cost_allocation
6160
}
6261
}
62+
{% if beta_cluster %}
6363
dynamic "confidential_nodes" {
6464
for_each = local.confidential_node_config
6565
content {
@@ -598,7 +598,7 @@ resource "google_container_node_pool" "windows_pools" {
598598
for_each = local.node_pools
599599
{% else %}
600600
for_each = local.windows_node_pools
601-
{% endif %}
601+
{% endif %}
602602
{% if update_variant %}
603603
name = { for k, v in random_id.name : k => v.hex }[each.key]
604604
{% else %}
@@ -645,7 +645,7 @@ resource "google_container_node_pool" "windows_pools" {
645645
type = lookup(placement_policy.value, "placement_policy", null)
646646
}
647647
}
648-
648+
649649
dynamic "network_config" {
650650
for_each = length(lookup(each.value, "pod_range", "")) > 0 ? [each.value] : []
651651
content {

autogen/main/variables.tf.tmpl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,11 @@ variable "node_pools_linux_node_configs_sysctls" {
196196
{% endif %}
197197
{% endif %}
198198

199-
{% if beta_cluster %}
200199
variable "enable_cost_allocation" {
201200
type = bool
202201
description = "Enables Cost Allocation Feature and the cluster name and namespace of your GKE workloads appear in the labels field of the billing export to BigQuery"
203202
default = false
204203
}
205-
{% endif %}
206204
variable "resource_usage_export_dataset_id" {
207205
type = string
208206
description = "The ID of a BigQuery Dataset for using BigQuery as the destination of resource usage export."

autogen/main/versions.tf.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ terraform {
2424
required_providers {
2525
google-beta = {
2626
source = "hashicorp/google-beta"
27-
version = ">= 4.36.0, < 5.0"
27+
version = ">= 4.42.0, < 5.0"
2828
}
2929
kubernetes = {
3030
source = "hashicorp/kubernetes"

cluster.tf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ resource "google_container_cluster" "primary" {
4747
channel = release_channel.value.channel
4848
}
4949
}
50+
dynamic "cost_management_config" {
51+
for_each = var.enable_cost_allocation ? [1] : []
52+
content {
53+
enabled = var.enable_cost_allocation
54+
}
55+
}
5056

5157
subnetwork = "projects/${local.network_project_id}/regions/${local.region}/subnetworks/${var.subnetwork}"
5258

@@ -303,7 +309,6 @@ resource "google_container_cluster" "primary" {
303309
resource "google_container_node_pool" "pools" {
304310
provider = google
305311
for_each = local.node_pools
306-
307312
name = each.key
308313
project = var.project_id
309314
location = local.location
@@ -458,7 +463,6 @@ resource "google_container_node_pool" "pools" {
458463
resource "google_container_node_pool" "windows_pools" {
459464
provider = google
460465
for_each = local.windows_node_pools
461-
462466
name = each.key
463467
project = var.project_id
464468
location = local.location

docs/upgrading_to_v24.0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ To avoid this, it is possible to edit the remote state of the `random_id` resour
5959

6060
### Minimum Google Provider versions
6161

62-
Minimum Google Provider versions have been updated to `4.36.0`.
62+
Minimum Google Provider versions have been updated to `4.42.0`.

examples/simple_regional/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ module "gke" {
3838
ip_range_services = var.ip_range_services
3939
create_service_account = false
4040
service_account = var.compute_engine_service_account
41+
enable_cost_allocation = true
4142
enable_binary_authorization = var.enable_binary_authorization
4243
skip_provisioners = var.skip_provisioners
4344
}

modules/beta-autopilot-private-cluster/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ terraform {
2121
required_providers {
2222
google-beta = {
2323
source = "hashicorp/google-beta"
24-
version = ">= 4.36.0, < 5.0"
24+
version = ">= 4.42.0, < 5.0"
2525
}
2626
kubernetes = {
2727
source = "hashicorp/kubernetes"

modules/beta-autopilot-public-cluster/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ terraform {
2121
required_providers {
2222
google-beta = {
2323
source = "hashicorp/google-beta"
24-
version = ">= 4.36.0, < 5.0"
24+
version = ">= 4.42.0, < 5.0"
2525
}
2626
kubernetes = {
2727
source = "hashicorp/kubernetes"

modules/beta-private-cluster-update-variant/cluster.tf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,6 @@ resource "random_id" "name" {
524524
resource "google_container_node_pool" "pools" {
525525
provider = google-beta
526526
for_each = local.node_pools
527-
528527
name = { for k, v in random_id.name : k => v.hex }[each.key]
529528
project = var.project_id
530529
location = local.location
@@ -732,7 +731,6 @@ resource "google_container_node_pool" "pools" {
732731
resource "google_container_node_pool" "windows_pools" {
733732
provider = google-beta
734733
for_each = local.windows_node_pools
735-
736734
name = { for k, v in random_id.name : k => v.hex }[each.key]
737735
project = var.project_id
738736
location = local.location

0 commit comments

Comments
 (0)