Skip to content

Commit 0fc38c9

Browse files
feat!: Make ILB adc compliant. Change input variable project to project_id (#167)
1 parent 082a1e1 commit 0fc38c9

File tree

13 files changed

+416
-206
lines changed

13 files changed

+416
-206
lines changed

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# Make will use bash instead of sh
1616
SHELL := /usr/bin/env bash
1717

18-
DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 1.22
18+
DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 1.23
1919
DOCKER_IMAGE_DEVELOPER_TOOLS := cft/developer-tools
2020
REGISTRY_URL := gcr.io/cloud-foundation-cicd
2121

@@ -65,6 +65,7 @@ docker_test_integration:
6565
.PHONY: docker_test_lint
6666
docker_test_lint:
6767
docker run --rm -it \
68+
-e ENABLE_BPMETADATA=1 \
6869
-v $(CURDIR):/workspace \
6970
$(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \
7071
/usr/local/bin/test_lint.sh
@@ -73,6 +74,7 @@ docker_test_lint:
7374
.PHONY: docker_generate_docs
7475
docker_generate_docs:
7576
docker run --rm -it \
77+
-e ENABLE_BPMETADATA=1 \
7678
-v $(CURDIR):/workspace \
7779
$(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \
7880
/bin/bash -c 'source /usr/local/bin/task_helper_functions.sh && generate_docs'

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ The following guides are available to assist with upgrades:
1515

1616
- [1.X -> 2.0](./docs/upgrading_to_lb_internal_v2.0.md)
1717
- [5.x -> 6.x](./docs/upgrading_to_lb_internal_v6.md)
18+
- [7.x -> 8.x](./docs/upgrading_to_lb_internal_v8.md)
1819

1920
## Usage
2021

@@ -63,32 +64,32 @@ module "gce-ilb" {
6364

6465
| Name | Description | Type | Default | Required |
6566
|------|-------------|------|---------|:--------:|
66-
| all\_ports | Boolean for all\_ports setting on forwarding rule. The `ports` or `all_ports` are mutually exclusive. | `bool` | `null` | no |
67-
| backends | List of backends, should be a map of key-value pairs for each backend, must have the 'group' key. | `list(any)` | n/a | yes |
67+
| all\_ports | Boolean for all\_ports setting on forwarding rule. The `ports` or `all_ports` are mutually exclusive. | `bool` | `false` | no |
68+
| backends | List of backends, should be a map of key-value pairs for each backend, must have the 'group' key. | <pre>list(object({<br> group = string<br> description = optional(string)<br> failover = optional(bool)<br> }))</pre> | n/a | yes |
6869
| connection\_draining\_timeout\_sec | Time for which instance will be drained | `number` | `null` | no |
6970
| create\_backend\_firewall | Controls if firewall rules for the backends will be created or not. Health-check firewall rules are controlled separately. | `bool` | `true` | no |
7071
| create\_health\_check\_firewall | Controls if firewall rules for the health check will be created or not. If this rule is not present backend healthcheck will fail. | `bool` | `true` | no |
7172
| firewall\_enable\_logging | Controls if firewall rules that are created are to have logging configured. This will be ignored for firewall rules that are not created. | `bool` | `false` | no |
7273
| global\_access | Allow all regions on the same VPC network access. | `bool` | `false` | no |
73-
| health\_check | Health check to determine whether instances are responsive and able to do work | <pre>object({<br> type = string<br> check_interval_sec = optional(number)<br> healthy_threshold = optional(number)<br> timeout_sec = optional(number)<br> unhealthy_threshold = optional(number)<br> response = optional(string)<br> proxy_header = optional(string)<br> port = optional(number)<br> port_name = optional(string)<br> request = optional(string)<br> request_path = optional(string)<br> host = optional(string)<br> enable_log = optional(bool)<br> })</pre> | n/a | yes |
74+
| health\_check | Health check to determine whether instances are responsive and able to do work | <pre>object({<br> type = string<br> check_interval_sec = optional(number)<br> healthy_threshold = optional(number)<br> timeout_sec = optional(number)<br> unhealthy_threshold = optional(number)<br> response = optional(string)<br> proxy_header = optional(string)<br> port = optional(number, 80)<br> port_name = optional(string)<br> request = optional(string)<br> request_path = optional(string)<br> host = optional(string)<br> enable_log = optional(bool, false)<br> })</pre> | n/a | yes |
7475
| ip\_address | IP address of the internal load balancer, if empty one will be assigned. Default is empty. | `string` | `null` | no |
7576
| ip\_protocol | The IP protocol for the backend and frontend forwarding rule. TCP or UDP. | `string` | `"TCP"` | no |
7677
| is\_mirroring\_collector | Indicates whether or not this load balancer can be used as a collector for packet mirroring. This can only be set to true for load balancers that have their loadBalancingScheme set to INTERNAL. | `bool` | `false` | no |
7778
| labels | The labels to attach to resources created by this module. | `map(string)` | `{}` | no |
7879
| name | Name for the forwarding rule and prefix for supporting resources. | `string` | n/a | yes |
7980
| network | Name of the network to create resources in. | `string` | `"default"` | no |
80-
| network\_project | Name of the project for the network. Useful for shared VPC. Default is var.project. | `string` | `""` | no |
81-
| ports | List of ports to forward to backend services. Max is 5. The `ports` or `all_ports` are mutually exclusive. | `list(string)` | `null` | no |
82-
| project | The project to deploy to, if not set the default provider project is used. | `string` | `""` | no |
83-
| region | Region for cloud resources. | `string` | `"us-central1"` | no |
81+
| network\_project | Name of the project for the network. Useful for shared VPC. Default is var.project\_id. | `string` | `""` | no |
82+
| ports | List of ports to forward to backend services. Max is 5. The `ports` or `all_ports` are mutually exclusive. | `list(string)` | <pre>[<br> "80"<br>]</pre> | no |
83+
| project\_id | The project\_id to deploy to. | `string` | n/a | yes |
84+
| region | Region for cloud resources. | `string` | n/a | yes |
8485
| service\_label | Service label is used to create internal DNS name | `string` | `null` | no |
8586
| session\_affinity | The session affinity for the backends example: NONE, CLIENT\_IP. Default is `NONE`. | `string` | `"NONE"` | no |
8687
| source\_ip\_ranges | List of source ip ranges for traffic between the internal load balancer. | `list(string)` | `null` | no |
8788
| source\_service\_accounts | List of source service accounts for traffic between the internal load balancer. | `list(string)` | `null` | no |
88-
| source\_tags | List of source tags for traffic between the internal load balancer. | `list(string)` | n/a | yes |
89+
| source\_tags | List of source tags for traffic between the internal load balancer. | `list(string)` | `[]` | no |
8990
| subnetwork | Name of the subnetwork to create resources in. | `string` | `"default"` | no |
9091
| target\_service\_accounts | List of target service accounts for traffic between the internal load balancer. | `list(string)` | `null` | no |
91-
| target\_tags | List of target tags for traffic between the internal load balancer. | `list(string)` | n/a | yes |
92+
| target\_tags | List of target tags for traffic between the internal load balancer. | `list(string)` | `[]` | no |
9293

9394
## Outputs
9495

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Upgrading to v8.0
2+
3+
This version introduces breaking changes to align the module with Google's **Application Design Center (ADC)** compliance standards.
4+
5+
## Breaking Changes
6+
7+
### Variable Rename: `project` to `project_id`
8+
9+
To maintain consistency across all Google Cloud blueprints and modules, the `project` input variable has been renamed to `project_id`. This change is required for ADC compliance.
10+
11+
#### Before
12+
```hcl
13+
module "gce-ilb" {
14+
source = "terraform-google-modules/lb-internal/google"
15+
version = "~> 7.0"
16+
project = "my-project-id"
17+
# ...
18+
}
19+
After
20+
module "gce-ilb" {
21+
source = "terraform-google-modules/lb-internal/google"
22+
version = "~> 8.0"
23+
project_id = "my-project-id"
24+
# ...
25+
}

examples/minimal/main.tf

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,9 @@ resource "google_compute_subnetwork" "test" {
5959

6060
# [START cloudloadbalancing_int_tcp_udp_minimal]
6161
module "test_ilb" {
62-
source = "GoogleCloudPlatform/lb-internal/google"
63-
version = "~> 7.0"
62+
source = "../../"
6463

65-
project = var.project_id
64+
project_id = var.project_id
6665
network = google_compute_network.test.name
6766
subnetwork = google_compute_subnetwork.test.name
6867
region = var.region

examples/simple/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This example creates 3 instance groups. The first group is in us-central1-b and
1212
| Name | Description | Type | Default | Required |
1313
|------|-------------|------|---------|:--------:|
1414
| network | Name of the network to create resources in. | `string` | n/a | yes |
15-
| project | The project id to deploy to | `string` | n/a | yes |
15+
| project\_id | The project id to deploy to | `string` | n/a | yes |
1616
| region | Region for cloud resources. | `string` | n/a | yes |
1717
| service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template#service_account | <pre>object({<br> email = string<br> scopes = set(string)<br> })</pre> | n/a | yes |
1818
| subnetwork | Name of the subnetwork to create resources in. | `string` | n/a | yes |

examples/simple/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module "gce-lb-fr" {
1919
version = "~> 5.0"
2020
region = var.region
2121
network = var.network
22-
project = var.project
22+
project = var.project_id
2323
name = "group1-lb"
2424
service_port = local.named_ports[0].port
2525
target_tags = ["allow-group1"]
@@ -29,7 +29,7 @@ module "gce-ilb" {
2929
source = "terraform-google-modules/lb-internal/google"
3030
version = "~> 5.0"
3131

32-
project = var.project
32+
project_id = var.project_id
3333
region = var.region
3434
name = "group-ilb"
3535
ports = [local.named_ports[0].port]

examples/simple/mig.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
module "instance_template1" {
1818
source = "terraform-google-modules/vm/google//modules/instance_template"
1919
version = "~> 12.0"
20-
project_id = var.project
20+
project_id = var.project_id
2121
subnetwork = var.subnetwork
2222
subnetwork_project = var.subnetwork_project
2323
service_account = var.service_account
@@ -28,7 +28,7 @@ module "instance_template1" {
2828
module "instance_template2" {
2929
source = "terraform-google-modules/vm/google//modules/instance_template"
3030
version = "~> 12.0"
31-
project_id = var.project
31+
project_id = var.project_id
3232
subnetwork = var.subnetwork
3333
subnetwork_project = var.subnetwork_project
3434
service_account = var.service_account
@@ -39,7 +39,7 @@ module "instance_template2" {
3939
module "instance_template3" {
4040
source = "terraform-google-modules/vm/google//modules/instance_template"
4141
version = "~> 12.0"
42-
project_id = var.project
42+
project_id = var.project_id
4343
subnetwork = var.subnetwork
4444
subnetwork_project = var.subnetwork_project
4545
service_account = var.service_account
@@ -50,7 +50,7 @@ module "instance_template3" {
5050
module "mig1" {
5151
source = "terraform-google-modules/vm/google//modules/mig"
5252
version = "~> 12.0"
53-
project_id = var.project
53+
project_id = var.project_id
5454
region = var.region
5555
target_pools = [module.gce-lb-fr.target_pool]
5656
instance_template = module.instance_template1.self_link
@@ -61,7 +61,7 @@ module "mig1" {
6161
module "mig2" {
6262
source = "terraform-google-modules/vm/google//modules/mig"
6363
version = "~> 12.0"
64-
project_id = var.project
64+
project_id = var.project_id
6565
region = var.region
6666
hostname = "mig2"
6767
instance_template = module.instance_template2.self_link
@@ -71,7 +71,7 @@ module "mig2" {
7171
module "mig3" {
7272
source = "terraform-google-modules/vm/google//modules/mig"
7373
version = "~> 12.0"
74-
project_id = var.project
74+
project_id = var.project_id
7575
region = var.region
7676
hostname = "mig3"
7777
instance_template = module.instance_template3.self_link

examples/simple/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ variable "subnetwork_project" {
4242
type = string
4343
}
4444

45-
variable "project" {
45+
variable "project_id" {
4646
description = "The project id to deploy to"
4747
type = string
4848
}

main.tf

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818
# Using a data source here to access both self_link and name by looking up the network name.
1919
data "google_compute_network" "network" {
2020
name = var.network
21-
project = var.network_project == "" ? var.project : var.network_project
21+
project = var.network_project == "" ? var.project_id : var.network_project
2222
}
2323

2424
data "google_compute_subnetwork" "network" {
2525
name = var.subnetwork
26-
project = var.network_project == "" ? var.project : var.network_project
26+
project = var.network_project == "" ? var.project_id : var.network_project
2727
region = var.region
2828
}
2929

3030
resource "google_compute_forwarding_rule" "default" {
31-
project = var.project
31+
project = var.project_id
3232
name = var.name
3333
region = var.region
3434
network = data.google_compute_network.network.self_link
@@ -46,7 +46,7 @@ resource "google_compute_forwarding_rule" "default" {
4646
}
4747

4848
resource "google_compute_region_backend_service" "default" {
49-
project = var.project
49+
project = var.project_id
5050
name = {
5151
"tcp" = "${var.name}-with-tcp-hc",
5252
"http" = "${var.name}-with-http-hc",
@@ -74,7 +74,7 @@ resource "google_compute_region_backend_service" "default" {
7474
resource "google_compute_health_check" "tcp" {
7575
provider = google-beta
7676
count = var.health_check["type"] == "tcp" ? 1 : 0
77-
project = var.project
77+
project = var.project_id
7878
name = "${var.name}-hc-tcp"
7979

8080
timeout_sec = var.health_check["timeout_sec"]
@@ -101,7 +101,7 @@ resource "google_compute_health_check" "tcp" {
101101
resource "google_compute_health_check" "http" {
102102
provider = google-beta
103103
count = var.health_check["type"] == "http" ? 1 : 0
104-
project = var.project
104+
project = var.project_id
105105
name = "${var.name}-hc-http"
106106

107107
timeout_sec = var.health_check["timeout_sec"]
@@ -129,7 +129,7 @@ resource "google_compute_health_check" "http" {
129129
resource "google_compute_health_check" "https" {
130130
provider = google-beta
131131
count = var.health_check["type"] == "https" ? 1 : 0
132-
project = var.project
132+
project = var.project_id
133133
name = "${var.name}-hc-https"
134134

135135
timeout_sec = var.health_check["timeout_sec"]
@@ -156,7 +156,7 @@ resource "google_compute_health_check" "https" {
156156

157157
resource "google_compute_firewall" "default-ilb-fw" {
158158
count = var.create_backend_firewall ? 1 : 0
159-
project = var.network_project == "" ? var.project : var.network_project
159+
project = var.network_project == "" ? var.project_id : var.network_project
160160
name = "${var.name}-ilb-fw"
161161
network = data.google_compute_network.network.name
162162

@@ -166,9 +166,9 @@ resource "google_compute_firewall" "default-ilb-fw" {
166166
}
167167

168168
source_ranges = var.source_ip_ranges
169-
source_tags = var.source_tags
169+
source_tags = length(var.source_tags) > 0 ? var.source_tags : null
170170
source_service_accounts = var.source_service_accounts
171-
target_tags = var.target_tags
171+
target_tags = length(var.target_tags) > 0 ? var.target_tags : null
172172
target_service_accounts = var.target_service_accounts
173173

174174
dynamic "log_config" {
@@ -181,7 +181,7 @@ resource "google_compute_firewall" "default-ilb-fw" {
181181

182182
resource "google_compute_firewall" "default-hc" {
183183
count = var.create_health_check_firewall ? 1 : 0
184-
project = var.network_project == "" ? var.project : var.network_project
184+
project = var.network_project == "" ? var.project_id : var.network_project
185185
name = "${var.name}-hc"
186186
network = data.google_compute_network.network.name
187187

@@ -191,7 +191,7 @@ resource "google_compute_firewall" "default-hc" {
191191
}
192192

193193
source_ranges = ["130.211.0.0/22", "35.191.0.0/16"]
194-
target_tags = var.target_tags
194+
target_tags = length(var.target_tags) > 0 ? var.target_tags : null
195195
target_service_accounts = var.target_service_accounts
196196

197197
dynamic "log_config" {

0 commit comments

Comments
 (0)