Skip to content

Commit 1890130

Browse files
jimrightYazan Al-Yasin
andcommitted
Add provider definitions and resolve lint issues
Signed-off-by: Jim Enright <[email protected]> Co-authored-by: Yazan Al-Yasin <[email protected]>
1 parent d741c0a commit 1890130

File tree

9 files changed

+69
-47
lines changed

9 files changed

+69
-47
lines changed

modules/hosts/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@ The sample `terraform.tfvars.sample` describes the required inputs for the examp
2222

2323
## Requirements
2424

25-
No requirements.
25+
| Name | Version |
26+
|------|---------|
27+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | > 1.3.0 |
28+
| <a name="requirement_google"></a> [google](#requirement\_google) | >= 6.12 |
2629

2730
## Providers
2831

2932
| Name | Version |
3033
|------|---------|
31-
| <a name="provider_google"></a> [google](#provider\_google) | n/a |
34+
| <a name="provider_google"></a> [google](#provider\_google) | >= 6.12 |
3235

3336
## Modules
3437

@@ -48,7 +51,6 @@ No modules.
4851
|------|-------------|------|---------|:--------:|
4952
| <a name="input_name"></a> [name](#input\_name) | Instance base name. If 'quantity' is 0, this is the exact name of the single instance. If 'quantity' > 0, name will be <name>-NN. | `string` | n/a | yes |
5053
| <a name="input_project_id"></a> [project\_id](#input\_project\_id) | GCP project ID where instances will be created. | `string` | n/a | yes |
51-
| <a name="input_region"></a> [region](#input\_region) | GCP region (e.g., us-central1) for the instances (used for regional resources if any, zone is primary for instances). | `string` | n/a | yes |
5254
| <a name="input_ssh_public_key"></a> [ssh\_public\_key](#input\_ssh\_public\_key) | The contents of the SSH public key to be added to the instance metadata for SSH access. | `string` | n/a | yes |
5355
| <a name="input_subnet_ids"></a> [subnet\_ids](#input\_subnet\_ids) | List of subnet self-links or names to assign instances to. Instances will be distributed across these subnets. Must not be empty if instances are created. | `list(string)` | n/a | yes |
5456
| <a name="input_zones"></a> [zones](#input\_zones) | GCP zone (e.g., us-central1-a) where instances will be created. | `list(string)` | n/a | yes |

modules/hosts/examples/ex01-minimal_inputs/main.tf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ locals {
4949
module "ex01_network" {
5050
source = "../../../network"
5151

52-
project_id = var.project_id
5352
region = var.region
54-
zones = local.zones
5553
vpc_name = "${var.prefix}-pvc-base"
5654
vpc_exists = false
5755
prefix = var.prefix
@@ -60,15 +58,12 @@ module "ex01_network" {
6058
public_subnets = var.public_subnets_config
6159
private_subnets = var.private_subnets_config
6260

63-
asset_tags = local.asset_tags
64-
6561
}
6662

6763
module "ex01_nodes" {
6864
source = "../../"
6965

7066
project_id = var.project_id
71-
region = var.region
7267
zones = local.zones
7368
name = "${var.prefix}-hosts"
7469
quantity = 3

modules/hosts/provider.tf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright 2025 Cloudera, Inc. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
terraform {
16+
required_providers {
17+
google = {
18+
source = "hashicorp/google"
19+
version = ">= 6.12"
20+
}
21+
}
22+
23+
required_version = "> 1.3.0"
24+
}

modules/hosts/variables.tf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ variable "project_id" {
2020
description = "GCP project ID where instances will be created."
2121
}
2222

23-
variable "region" {
24-
type = string
25-
description = "GCP region (e.g., us-central1) for the instances (used for regional resources if any, zone is primary for instances)."
26-
}
27-
2823
variable "zones" {
2924
type = list(string)
3025
description = "GCP zone (e.g., us-central1-a) where instances will be created."

modules/network/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@ The sample `terraform.tfvars.sample` describes the required inputs for the examp
2222

2323
## Requirements
2424

25-
No requirements.
25+
| Name | Version |
26+
|------|---------|
27+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | > 1.3.0 |
28+
| <a name="requirement_google"></a> [google](#requirement\_google) | >= 6.12 |
2629

2730
## Providers
2831

2932
| Name | Version |
3033
|------|---------|
31-
| <a name="provider_google"></a> [google](#provider\_google) | n/a |
34+
| <a name="provider_google"></a> [google](#provider\_google) | >= 6.12 |
3235

3336
## Modules
3437

@@ -51,12 +54,9 @@ No modules.
5154
| Name | Description | Type | Default | Required |
5255
|------|-------------|------|---------|:--------:|
5356
| <a name="input_prefix"></a> [prefix](#input\_prefix) | Deployment prefix used for naming all cloud-provider assets created by this module. | `string` | n/a | yes |
54-
| <a name="input_project_id"></a> [project\_id](#input\_project\_id) | The GCP project ID where resources will be deployed. | `string` | n/a | yes |
5557
| <a name="input_region"></a> [region](#input\_region) | The GCP region where resources will be deployed. | `string` | n/a | yes |
5658
| <a name="input_vpc_exists"></a> [vpc\_exists](#input\_vpc\_exists) | Use existing GCP VPC network. | `bool` | n/a | yes |
5759
| <a name="input_vpc_name"></a> [vpc\_name](#input\_vpc\_name) | The name of the GCP VPC network into which subnets and other network resources will be deployed. | `string` | n/a | yes |
58-
| <a name="input_zones"></a> [zones](#input\_zones) | Zones in GCP region where resources will be deployed. | `list(string)` | n/a | yes |
59-
| <a name="input_asset_tags"></a> [asset\_tags](#input\_asset\_tags) | Map of labels applied to all cloud-provider assets created by this module. These are GCP resource labels. | `map(string)` | `{}` | no |
6060
| <a name="input_base_cidr_block"></a> [base\_cidr\_block](#input\_base\_cidr\_block) | The base CIDR block (e.g., '10.50.0.0/16') from which default public and private subnet CIDRs will be derived. This variable is required if 'public\_subnets' or 'private\_subnets' are not explicitly provided. | `string` | `"10.10.0.0/16"` | no |
6161
| <a name="input_private_subnets"></a> [private\_subnets](#input\_private\_subnets) | A list of objects defining private subnets. Each object requires 'name', 'cidr', and 'labels' (a map of strings). If this list is empty, a single default private subnet will be created using 'base\_cidr\_block'. | <pre>list(object({<br/> name = string<br/> cidr = string<br/> labels = map(string) # Renamed from 'tags' to 'labels' for clarity and consistency with GCP resource labels<br/> }))</pre> | `[]` | no |
6262
| <a name="input_public_subnets"></a> [public\_subnets](#input\_public\_subnets) | A list of objects defining public subnets. Each object requires 'name', 'cidr', and 'labels' (a map of strings). If this list is empty, a single default public subnet will be created using 'base\_cidr\_block'. | <pre>list(object({<br/> name = string<br/> cidr = string<br/> labels = map(string) # Renamed from 'tags' to 'labels' for clarity and consistency with GCP resource labels<br/> }))</pre> | `[]` | no |
@@ -72,7 +72,7 @@ No modules.
7272
| <a name="output_region"></a> [region](#output\_region) | The GCP region used for deployment, as provided in the input variables. |
7373
| <a name="output_router_name"></a> [router\_name](#output\_router\_name) | The name of the created Cloud Router resource. |
7474
| <a name="output_vpc_name"></a> [vpc\_name](#output\_vpc\_name) | The GCP VPC network name used for deployment, as provided in the input variables. |
75-
| <a name="output_vpc_private_cidr_block"></a> [vpc\_private\_cidr\_block](#output\_vpc\_private\_cidr\_block) | n/a |
76-
| <a name="output_vpc_public_cidr_block"></a> [vpc\_public\_cidr\_block](#output\_vpc\_public\_cidr\_block) | n/a |
75+
| <a name="output_vpc_private_cidr_block"></a> [vpc\_private\_cidr\_block](#output\_vpc\_private\_cidr\_block) | Value of the first created private subnet's CIDR block. |
76+
| <a name="output_vpc_public_cidr_block"></a> [vpc\_public\_cidr\_block](#output\_vpc\_public\_cidr\_block) | Value of the first created public subnet's CIDR block. |
7777
| <a name="output_vpc_self_link"></a> [vpc\_self\_link](#output\_vpc\_self\_link) | Self-link of the VPC network fetched by the module. |
7878
<!-- END_TF_DOCS -->

modules/network/examples/ex01-minimal_inputs/main.tf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ locals {
4747
module "ex01_network" {
4848
source = "../.."
4949

50-
project_id = var.project_id
5150
region = var.region
52-
zones = local.zones
5351
vpc_name = "${var.prefix}-pvc-base"
5452
vpc_exists = false
5553
prefix = var.prefix
@@ -58,6 +56,4 @@ module "ex01_network" {
5856
public_subnets = var.public_subnets_config
5957
private_subnets = var.private_subnets_config
6058

61-
asset_tags = local.asset_tags
62-
6359
}

modules/network/outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,14 @@ output "created_private_subnets" {
5959

6060
output "vpc_private_cidr_block" {
6161
value = google_compute_subnetwork.pvc_base_private[0].ip_cidr_range
62+
63+
description = "Value of the first created private subnet's CIDR block."
6264
}
6365

6466
output "vpc_public_cidr_block" {
6567
value = google_compute_subnetwork.pvc_base_public[0].ip_cidr_range
68+
69+
description = "Value of the first created public subnet's CIDR block."
6670
}
6771

6872
output "router_name" {

modules/network/provider.tf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright 2025 Cloudera, Inc. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
terraform {
16+
required_providers {
17+
google = {
18+
source = "hashicorp/google"
19+
version = ">= 6.12"
20+
}
21+
}
22+
23+
required_version = "> 1.3.0"
24+
}

modules/network/variables.tf

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,41 +12,18 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# File: tf_cluster_gcp/modules/network/variables.tf
16-
1715
# ------- Required Variables -------
1816

19-
variable "asset_tags" {
20-
type = map(string)
21-
default = {}
22-
description = "Map of labels applied to all cloud-provider assets created by this module. These are GCP resource labels."
23-
}
24-
2517
variable "prefix" {
2618
type = string
2719
description = "Deployment prefix used for naming all cloud-provider assets created by this module."
2820
}
2921

30-
variable "project_id" {
31-
type = string
32-
description = "The GCP project ID where resources will be deployed."
33-
}
34-
3522
variable "region" {
3623
type = string
3724
description = "The GCP region where resources will be deployed."
3825
}
3926

40-
variable "zones" {
41-
type = list(string)
42-
description = "Zones in GCP region where resources will be deployed."
43-
44-
validation {
45-
condition = length(var.zones) != 0
46-
error_message = "No zones returned! Invalid GCP Region: ${var.region}"
47-
}
48-
}
49-
5027
variable "vpc_name" {
5128
type = string
5229
description = "The name of the GCP VPC network into which subnets and other network resources will be deployed."
@@ -68,6 +45,11 @@ variable "base_cidr_block" {
6845
}
6946
}
7047

48+
# variable "asset_tags" {
49+
# type = map(string)
50+
# default = {}
51+
# description = "Map of labels applied to all cloud-provider assets created by this module. These are GCP resource labels."
52+
# }
7153
# ------- Network Resources Configuration Variables -------
7254

7355
variable "public_subnets" {

0 commit comments

Comments
 (0)