Skip to content

Commit bb7c3ce

Browse files
authored
fix: Fix attribution for safer cluster modules (#830)
1 parent 923eff4 commit bb7c3ce

File tree

38 files changed

+151
-34
lines changed

38 files changed

+151
-34
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ Then perform the following commands on the root folder:
123123

124124
| Name | Description | Type | Default | Required |
125125
|------|-------------|------|---------|:--------:|
126+
| \_parent\_module | (Internal) Parent module which should be referenced in API calls. | `string` | `""` | no |
126127
| add\_cluster\_firewall\_rules | Create additional firewall rules | `bool` | `false` | no |
127128
| add\_shadow\_firewall\_rules | Create GKE shadow firewall (the same as default firewall rules with firewall logs enabled). | `bool` | `false` | no |
128129
| basic\_auth\_password | The password to be used with Basic Authentication. | `string` | `""` | no |

autogen/main/variables.tf.tmpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,3 +625,9 @@ variable "enable_tpu" {
625625
default = false
626626
}
627627
{% endif %}
628+
629+
variable "_parent_module" {
630+
type = string
631+
description = "(Internal) Parent module which should be referenced in API calls."
632+
default = ""
633+
}

autogen/main/versions.tf.tmpl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
{% set module_path_str = module_path|string %}
1818
{% set module_registry_name = module_path_str.split('/')[-1] %}
1919

20+
locals {
21+
blueprint_name = join("/", compact([var._parent_module, "terraform-google-kubernetes-engine{% if module_registry_name %}:{{ module_registry_name }}{% endif %}/v13.0.0"]))
22+
}
23+
2024
terraform {
2125
required_version = ">=0.13"
2226

@@ -32,7 +36,7 @@ terraform {
3236
}
3337
}
3438
provider_meta "google-beta" {
35-
module_name = "blueprints/terraform/terraform-google-kubernetes-engine{% if module_registry_name %}:{{ module_registry_name }}{% endif %}/v13.0.0"
39+
module_name = "blueprints/terraform/${local.blueprint_name}"
3640
}
3741
{% else %}
3842
required_providers {
@@ -46,7 +50,7 @@ terraform {
4650
}
4751
}
4852
provider_meta "google" {
49-
module_name = "blueprints/terraform/terraform-google-kubernetes-engine{% if module_registry_name %}:{{ module_registry_name }}{% endif %}/v13.0.0"
53+
module_name = "blueprints/terraform/${local.blueprint_name}"
5054
}
5155
{% endif %}
5256
}

autogen/safer-cluster/main.tf.tmpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,4 +169,6 @@ module "gke" {
169169
gce_pd_csi_driver = var.gce_pd_csi_driver
170170

171171
notification_config_topic = var.notification_config_topic
172+
173+
_parent_module = local.blueprint_name
172174
}

autogen/safer-cluster/variables.tf.tmpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,3 +381,9 @@ variable "notification_config_topic" {
381381
description = "The desired Pub/Sub topic to which notifications will be sent by GKE. Format is projects/{project}/topics/{topic}."
382382
default = ""
383383
}
384+
385+
variable "_parent_module" {
386+
type = string
387+
description = "(Internal) Parent module which should be referenced in API calls."
388+
default = ""
389+
}

autogen/safer-cluster/versions.tf.tmpl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@
1919
{% set module_path_str = module_path|string %}
2020
{% set module_registry_name = module_path_str.split('/')[-1] %}
2121

22+
locals {
23+
blueprint_name = join("/", compact([var._parent_module, "terraform-google-kubernetes-engine{% if module_registry_name %}:{{ module_registry_name }}{% endif %}/v13.0.0"]))
24+
}
25+
2226
terraform {
2327
required_version = ">=0.13"
2428

2529
provider_meta "google-beta" {
26-
module_name = "blueprints/terraform/terraform-google-kubernetes-engine{% if module_registry_name %}:{{ module_registry_name }}{% endif %}/v13.0.0"
30+
module_name = "blueprints/terraform/${local.blueprint_name}"
2731
}
2832
}

examples/safer_cluster/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ This example illustrates how to instantiate the opinionated Safer Cluster module
77

88
| Name | Description | Type | Default | Required |
99
|------|-------------|------|---------|:--------:|
10-
| compute\_engine\_service\_account | Service account to associate to the nodes in the cluster | `string` | n/a | yes |
1110
| project\_id | The project ID to host the cluster in | `string` | n/a | yes |
1211
| region | The region to host the cluster in | `string` | `"us-central1"` | no |
1312

examples/safer_cluster/main.tf

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,18 @@ provider "kubernetes" {
4848
}
4949

5050
module "gke" {
51-
source = "../../modules/safer-cluster/"
52-
project_id = var.project_id
53-
name = "${local.cluster_type}-cluster-${random_string.suffix.result}"
54-
regional = true
55-
region = var.region
56-
network = module.gcp-network.network_name
57-
subnetwork = local.subnet_names[index(module.gcp-network.subnets_names, local.subnet_name)]
58-
ip_range_pods = local.pods_range_name
59-
ip_range_services = local.svc_range_name
60-
compute_engine_service_account = var.compute_engine_service_account
61-
master_ipv4_cidr_block = "172.16.0.0/28"
62-
add_cluster_firewall_rules = true
63-
firewall_inbound_ports = ["9443", "15017"]
51+
source = "../../modules/safer-cluster/"
52+
project_id = var.project_id
53+
name = "${local.cluster_type}-cluster-${random_string.suffix.result}"
54+
regional = true
55+
region = var.region
56+
network = module.gcp-network.network_name
57+
subnetwork = local.subnet_names[index(module.gcp-network.subnets_names, local.subnet_name)]
58+
ip_range_pods = local.pods_range_name
59+
ip_range_services = local.svc_range_name
60+
master_ipv4_cidr_block = "172.16.0.0/28"
61+
add_cluster_firewall_rules = true
62+
firewall_inbound_ports = ["9443", "15017"]
6463

6564
master_authorized_networks = [
6665
{

examples/safer_cluster/variables.tf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,3 @@ variable "region" {
2424
description = "The region to host the cluster in"
2525
default = "us-central1"
2626
}
27-
28-
variable "compute_engine_service_account" {
29-
type = string
30-
description = "Service account to associate to the nodes in the cluster"
31-
}

modules/beta-private-cluster-update-variant/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ Then perform the following commands on the root folder:
154154

155155
| Name | Description | Type | Default | Required |
156156
|------|-------------|------|---------|:--------:|
157+
| \_parent\_module | (Internal) Parent module which should be referenced in API calls. | `string` | `""` | no |
157158
| add\_cluster\_firewall\_rules | Create additional firewall rules | `bool` | `false` | no |
158159
| add\_shadow\_firewall\_rules | Create GKE shadow firewall (the same as default firewall rules with firewall logs enabled). | `bool` | `false` | no |
159160
| authenticator\_security\_group | The name of the RBAC security group for use with Google security groups in Kubernetes RBAC. Group name must be in format [email protected] | `string` | `null` | no |

0 commit comments

Comments
 (0)