Skip to content

Commit

Permalink
Use cluster ID for name output
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Naser committed Mar 29, 2022
1 parent 43b7728 commit 7e26938
Show file tree
Hide file tree
Showing 20 changed files with 44 additions and 19 deletions.
7 changes: 7 additions & 0 deletions autogen/main/main.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@ locals {
cluster_zones = sort(local.cluster_output_zones)

cluster_name = local.cluster_output_name
{% if autopilot_cluster != true %}
// node pool ID is in the form project/location/cluster/name
cluster_name_computed = element(split("/", google_container_node_pool.pools.id), length(split("/", google_container_node_pool.pools.id)) - 2)
{% else %}
// cluster ID is in the form project/location/name
cluster_name_computed = element(split("/", local.cluster_id), length(split("/", local.cluster_id)) - 1)
{% endif %}
cluster_network_tag = "gke-${var.name}"
cluster_ca_certificate = local.cluster_master_auth_map["cluster_ca_certificate"]
cluster_master_version = local.cluster_output_master_version
Expand Down
2 changes: 1 addition & 1 deletion autogen/main/outputs.tf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ output "cluster_id" {

output "name" {
description = "Cluster name"
value = local.cluster_name
value = local.cluster_name_computed
depends_on = [
/* Nominally, the cluster name is populated as soon as it is known to Terraform.
* However, the cluster may not be in a usable state yet. Therefore any
Expand Down
4 changes: 3 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ locals {
cluster_region = var.regional ? var.region : join("-", slice(split("-", local.cluster_location), 0, 2))
cluster_zones = sort(local.cluster_output_zones)

cluster_name = local.cluster_output_name
cluster_name = local.cluster_output_name
// node pool ID is in the form project/location/cluster/name
cluster_name_computed = element(split("/", google_container_node_pool.pools.id), length(split("/", google_container_node_pool.pools.id)) - 2)
cluster_network_tag = "gke-${var.name}"
cluster_ca_certificate = local.cluster_master_auth_map["cluster_ca_certificate"]
cluster_master_version = local.cluster_output_master_version
Expand Down
4 changes: 3 additions & 1 deletion modules/beta-autopilot-private-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ locals {
cluster_region = var.regional ? var.region : join("-", slice(split("-", local.cluster_location), 0, 2))
cluster_zones = sort(local.cluster_output_zones)

cluster_name = local.cluster_output_name
cluster_name = local.cluster_output_name
// cluster ID is in the form project/location/name
cluster_name_computed = element(split("/", local.cluster_id), length(split("/", local.cluster_id)) - 1)
cluster_network_tag = "gke-${var.name}"
cluster_ca_certificate = local.cluster_master_auth_map["cluster_ca_certificate"]
cluster_master_version = local.cluster_output_master_version
Expand Down
2 changes: 1 addition & 1 deletion modules/beta-autopilot-private-cluster/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ output "cluster_id" {

output "name" {
description = "Cluster name"
value = local.cluster_name
value = local.cluster_name_computed
depends_on = [
/* Nominally, the cluster name is populated as soon as it is known to Terraform.
* However, the cluster may not be in a usable state yet. Therefore any
Expand Down
4 changes: 3 additions & 1 deletion modules/beta-autopilot-public-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ locals {
cluster_region = var.regional ? var.region : join("-", slice(split("-", local.cluster_location), 0, 2))
cluster_zones = sort(local.cluster_output_zones)

cluster_name = local.cluster_output_name
cluster_name = local.cluster_output_name
// cluster ID is in the form project/location/name
cluster_name_computed = element(split("/", local.cluster_id), length(split("/", local.cluster_id)) - 1)
cluster_network_tag = "gke-${var.name}"
cluster_ca_certificate = local.cluster_master_auth_map["cluster_ca_certificate"]
cluster_master_version = local.cluster_output_master_version
Expand Down
2 changes: 1 addition & 1 deletion modules/beta-autopilot-public-cluster/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ output "cluster_id" {

output "name" {
description = "Cluster name"
value = local.cluster_name
value = local.cluster_name_computed
depends_on = [
/* Nominally, the cluster name is populated as soon as it is known to Terraform.
* However, the cluster may not be in a usable state yet. Therefore any
Expand Down
4 changes: 3 additions & 1 deletion modules/beta-private-cluster-update-variant/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ locals {
cluster_region = var.regional ? var.region : join("-", slice(split("-", local.cluster_location), 0, 2))
cluster_zones = sort(local.cluster_output_zones)

cluster_name = local.cluster_output_name
cluster_name = local.cluster_output_name
// node pool ID is in the form project/location/cluster/name
cluster_name_computed = element(split("/", google_container_node_pool.pools.id), length(split("/", google_container_node_pool.pools.id)) - 2)
cluster_network_tag = "gke-${var.name}"
cluster_ca_certificate = local.cluster_master_auth_map["cluster_ca_certificate"]
cluster_master_version = local.cluster_output_master_version
Expand Down
2 changes: 1 addition & 1 deletion modules/beta-private-cluster-update-variant/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ output "cluster_id" {

output "name" {
description = "Cluster name"
value = local.cluster_name
value = local.cluster_name_computed
depends_on = [
/* Nominally, the cluster name is populated as soon as it is known to Terraform.
* However, the cluster may not be in a usable state yet. Therefore any
Expand Down
4 changes: 3 additions & 1 deletion modules/beta-private-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ locals {
cluster_region = var.regional ? var.region : join("-", slice(split("-", local.cluster_location), 0, 2))
cluster_zones = sort(local.cluster_output_zones)

cluster_name = local.cluster_output_name
cluster_name = local.cluster_output_name
// node pool ID is in the form project/location/cluster/name
cluster_name_computed = element(split("/", google_container_node_pool.pools.id), length(split("/", google_container_node_pool.pools.id)) - 2)
cluster_network_tag = "gke-${var.name}"
cluster_ca_certificate = local.cluster_master_auth_map["cluster_ca_certificate"]
cluster_master_version = local.cluster_output_master_version
Expand Down
2 changes: 1 addition & 1 deletion modules/beta-private-cluster/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ output "cluster_id" {

output "name" {
description = "Cluster name"
value = local.cluster_name
value = local.cluster_name_computed
depends_on = [
/* Nominally, the cluster name is populated as soon as it is known to Terraform.
* However, the cluster may not be in a usable state yet. Therefore any
Expand Down
4 changes: 3 additions & 1 deletion modules/beta-public-cluster-update-variant/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ locals {
cluster_region = var.regional ? var.region : join("-", slice(split("-", local.cluster_location), 0, 2))
cluster_zones = sort(local.cluster_output_zones)

cluster_name = local.cluster_output_name
cluster_name = local.cluster_output_name
// node pool ID is in the form project/location/cluster/name
cluster_name_computed = element(split("/", google_container_node_pool.pools.id), length(split("/", google_container_node_pool.pools.id)) - 2)
cluster_network_tag = "gke-${var.name}"
cluster_ca_certificate = local.cluster_master_auth_map["cluster_ca_certificate"]
cluster_master_version = local.cluster_output_master_version
Expand Down
2 changes: 1 addition & 1 deletion modules/beta-public-cluster-update-variant/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ output "cluster_id" {

output "name" {
description = "Cluster name"
value = local.cluster_name
value = local.cluster_name_computed
depends_on = [
/* Nominally, the cluster name is populated as soon as it is known to Terraform.
* However, the cluster may not be in a usable state yet. Therefore any
Expand Down
4 changes: 3 additions & 1 deletion modules/beta-public-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ locals {
cluster_region = var.regional ? var.region : join("-", slice(split("-", local.cluster_location), 0, 2))
cluster_zones = sort(local.cluster_output_zones)

cluster_name = local.cluster_output_name
cluster_name = local.cluster_output_name
// node pool ID is in the form project/location/cluster/name
cluster_name_computed = element(split("/", google_container_node_pool.pools.id), length(split("/", google_container_node_pool.pools.id)) - 2)
cluster_network_tag = "gke-${var.name}"
cluster_ca_certificate = local.cluster_master_auth_map["cluster_ca_certificate"]
cluster_master_version = local.cluster_output_master_version
Expand Down
2 changes: 1 addition & 1 deletion modules/beta-public-cluster/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ output "cluster_id" {

output "name" {
description = "Cluster name"
value = local.cluster_name
value = local.cluster_name_computed
depends_on = [
/* Nominally, the cluster name is populated as soon as it is known to Terraform.
* However, the cluster may not be in a usable state yet. Therefore any
Expand Down
4 changes: 3 additions & 1 deletion modules/private-cluster-update-variant/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ locals {
cluster_region = var.regional ? var.region : join("-", slice(split("-", local.cluster_location), 0, 2))
cluster_zones = sort(local.cluster_output_zones)

cluster_name = local.cluster_output_name
cluster_name = local.cluster_output_name
// node pool ID is in the form project/location/cluster/name
cluster_name_computed = element(split("/", google_container_node_pool.pools.id), length(split("/", google_container_node_pool.pools.id)) - 2)
cluster_network_tag = "gke-${var.name}"
cluster_ca_certificate = local.cluster_master_auth_map["cluster_ca_certificate"]
cluster_master_version = local.cluster_output_master_version
Expand Down
2 changes: 1 addition & 1 deletion modules/private-cluster-update-variant/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ output "cluster_id" {

output "name" {
description = "Cluster name"
value = local.cluster_name
value = local.cluster_name_computed
depends_on = [
/* Nominally, the cluster name is populated as soon as it is known to Terraform.
* However, the cluster may not be in a usable state yet. Therefore any
Expand Down
4 changes: 3 additions & 1 deletion modules/private-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ locals {
cluster_region = var.regional ? var.region : join("-", slice(split("-", local.cluster_location), 0, 2))
cluster_zones = sort(local.cluster_output_zones)

cluster_name = local.cluster_output_name
cluster_name = local.cluster_output_name
// node pool ID is in the form project/location/cluster/name
cluster_name_computed = element(split("/", google_container_node_pool.pools.id), length(split("/", google_container_node_pool.pools.id)) - 2)
cluster_network_tag = "gke-${var.name}"
cluster_ca_certificate = local.cluster_master_auth_map["cluster_ca_certificate"]
cluster_master_version = local.cluster_output_master_version
Expand Down
2 changes: 1 addition & 1 deletion modules/private-cluster/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ output "cluster_id" {

output "name" {
description = "Cluster name"
value = local.cluster_name
value = local.cluster_name_computed
depends_on = [
/* Nominally, the cluster name is populated as soon as it is known to Terraform.
* However, the cluster may not be in a usable state yet. Therefore any
Expand Down
2 changes: 1 addition & 1 deletion outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ output "cluster_id" {

output "name" {
description = "Cluster name"
value = local.cluster_name
value = local.cluster_name_computed
depends_on = [
/* Nominally, the cluster name is populated as soon as it is known to Terraform.
* However, the cluster may not be in a usable state yet. Therefore any
Expand Down

0 comments on commit 7e26938

Please sign in to comment.