Skip to content

Commit 10ea608

Browse files
authored
feat!: cost_management_config is out of beta now (#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

+1
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

+3-3
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

-2
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

+1-1
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

+6-2
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

+1-1
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

+1
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

+1-1
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

+1-1
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

-2
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

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

+1-1
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/cluster.tf

-2
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,6 @@ resource "google_container_cluster" "primary" {
430430
resource "google_container_node_pool" "pools" {
431431
provider = google-beta
432432
for_each = local.node_pools
433-
434433
name = each.key
435434
project = var.project_id
436435
location = local.location
@@ -637,7 +636,6 @@ resource "google_container_node_pool" "pools" {
637636
resource "google_container_node_pool" "windows_pools" {
638637
provider = google-beta
639638
for_each = local.windows_node_pools
640-
641639
name = each.key
642640
project = var.project_id
643641
location = local.location

modules/beta-private-cluster/versions.tf

+1-1
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-public-cluster-update-variant/cluster.tf

-2
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,6 @@ resource "random_id" "name" {
505505
resource "google_container_node_pool" "pools" {
506506
provider = google-beta
507507
for_each = local.node_pools
508-
509508
name = { for k, v in random_id.name : k => v.hex }[each.key]
510509
project = var.project_id
511510
location = local.location
@@ -713,7 +712,6 @@ resource "google_container_node_pool" "pools" {
713712
resource "google_container_node_pool" "windows_pools" {
714713
provider = google-beta
715714
for_each = local.windows_node_pools
716-
717715
name = { for k, v in random_id.name : k => v.hex }[each.key]
718716
project = var.project_id
719717
location = local.location

modules/beta-public-cluster-update-variant/versions.tf

+1-1
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-public-cluster/cluster.tf

-2
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,6 @@ resource "google_container_cluster" "primary" {
411411
resource "google_container_node_pool" "pools" {
412412
provider = google-beta
413413
for_each = local.node_pools
414-
415414
name = each.key
416415
project = var.project_id
417416
location = local.location
@@ -618,7 +617,6 @@ resource "google_container_node_pool" "pools" {
618617
resource "google_container_node_pool" "windows_pools" {
619618
provider = google-beta
620619
for_each = local.windows_node_pools
621-
622620
name = each.key
623621
project = var.project_id
624622
location = local.location

modules/beta-public-cluster/versions.tf

+1-1
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/private-cluster-update-variant/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ Then perform the following commands on the root folder:
176176
| 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 |
177177
| dns\_cache | The status of the NodeLocal DNSCache addon. | `bool` | `false` | no |
178178
| enable\_binary\_authorization | Enable BinAuthZ Admission controller | `bool` | `false` | no |
179+
| 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 |
179180
| 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 |
180181
| enable\_private\_endpoint | (Beta) Whether the master's internal IP address is used as the cluster endpoint | `bool` | `false` | no |
181182
| enable\_private\_nodes | (Beta) Whether nodes have internal IP addresses only | `bool` | `false` | no |

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

+6-2
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

@@ -416,7 +422,6 @@ resource "random_id" "name" {
416422
resource "google_container_node_pool" "pools" {
417423
provider = google
418424
for_each = local.node_pools
419-
420425
name = { for k, v in random_id.name : k => v.hex }[each.key]
421426
project = var.project_id
422427
location = local.location
@@ -572,7 +577,6 @@ resource "google_container_node_pool" "pools" {
572577
resource "google_container_node_pool" "windows_pools" {
573578
provider = google
574579
for_each = local.windows_node_pools
575-
576580
name = { for k, v in random_id.name : k => v.hex }[each.key]
577581
project = var.project_id
578582
location = local.location

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

+5
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ variable "node_pools_metadata" {
181181
}
182182
}
183183

184+
variable "enable_cost_allocation" {
185+
type = bool
186+
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"
187+
default = false
188+
}
184189
variable "resource_usage_export_dataset_id" {
185190
type = string
186191
description = "The ID of a BigQuery Dataset for using BigQuery as the destination of resource usage export."

modules/private-cluster/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ Then perform the following commands on the root folder:
154154
| 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 |
155155
| dns\_cache | The status of the NodeLocal DNSCache addon. | `bool` | `false` | no |
156156
| enable\_binary\_authorization | Enable BinAuthZ Admission controller | `bool` | `false` | no |
157+
| 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 |
157158
| 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 |
158159
| enable\_private\_endpoint | (Beta) Whether the master's internal IP address is used as the cluster endpoint | `bool` | `false` | no |
159160
| enable\_private\_nodes | (Beta) Whether nodes have internal IP addresses only | `bool` | `false` | no |

modules/private-cluster/cluster.tf

+6-2
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

@@ -322,7 +328,6 @@ resource "google_container_cluster" "primary" {
322328
resource "google_container_node_pool" "pools" {
323329
provider = google
324330
for_each = local.node_pools
325-
326331
name = each.key
327332
project = var.project_id
328333
location = local.location
@@ -477,7 +482,6 @@ resource "google_container_node_pool" "pools" {
477482
resource "google_container_node_pool" "windows_pools" {
478483
provider = google
479484
for_each = local.windows_node_pools
480-
481485
name = each.key
482486
project = var.project_id
483487
location = local.location

modules/private-cluster/variables.tf

+5
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ variable "node_pools_metadata" {
181181
}
182182
}
183183

184+
variable "enable_cost_allocation" {
185+
type = bool
186+
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"
187+
default = false
188+
}
184189
variable "resource_usage_export_dataset_id" {
185190
type = string
186191
description = "The ID of a BigQuery Dataset for using BigQuery as the destination of resource usage export."

variables.tf

+5
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ variable "node_pools_metadata" {
181181
}
182182
}
183183

184+
variable "enable_cost_allocation" {
185+
type = bool
186+
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"
187+
default = false
188+
}
184189
variable "resource_usage_export_dataset_id" {
185190
type = string
186191
description = "The ID of a BigQuery Dataset for using BigQuery as the destination of resource usage export."

0 commit comments

Comments
 (0)