Skip to content

Commit

Permalink
fix: make project_id and region as required input for instance_template
Browse files Browse the repository at this point in the history
  • Loading branch information
q2w committed Dec 15, 2024
1 parent 0c9d75b commit 1df13ff
Show file tree
Hide file tree
Showing 16 changed files with 27 additions and 6 deletions.
1 change: 1 addition & 0 deletions examples/instance_template/additional_disks/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module "instance_template" {
version = "~> 12.0"

project_id = var.project_id
region = var.region
subnetwork = var.subnetwork
service_account = var.service_account
name_prefix = "additional-disks"
Expand Down
1 change: 1 addition & 0 deletions examples/instance_template/alias_ip_range/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module "instance_template" {
version = "~> 12.0"

project_id = var.project_id
region = var.region
subnetwork = var.subnetwork
service_account = var.service_account
name_prefix = "alias-ip-range"
Expand Down
1 change: 1 addition & 0 deletions examples/instance_template/simple/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module "instance_template" {
version = "~> 12.0"

project_id = var.project_id
region = var.region
subnetwork = var.subnetwork
stack_type = "IPV4_ONLY"
service_account = var.service_account
Expand Down
1 change: 1 addition & 0 deletions examples/mig/autoscaler/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module "instance_template" {
version = "~> 12.0"

project_id = var.project_id
region = var.region
subnetwork = var.subnetwork
service_account = var.service_account
}
Expand Down
1 change: 1 addition & 0 deletions examples/mig/healthcheck/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ module "instance_template" {
version = "~> 12.0"

project_id = var.project_id
region = var.region
subnetwork = google_compute_subnetwork.main.name
service_account = var.service_account
}
Expand Down
1 change: 1 addition & 0 deletions examples/mig/simple/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module "instance_template" {
version = "~> 12.0"

project_id = var.project_id
region = var.region
subnetwork = var.subnetwork
service_account = var.service_account
subnetwork_project = var.project_id
Expand Down
1 change: 1 addition & 0 deletions examples/umig/named_ports/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module "instance_template" {
version = "~> 12.0"

project_id = var.project_id
region = var.region
subnetwork = var.subnetwork
service_account = var.service_account
}
Expand Down
1 change: 1 addition & 0 deletions examples/umig/simple/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module "instance_template" {
version = "~> 12.0"

project_id = var.project_id
region = var.region
subnetwork = var.subnetwork
subnetwork_project = var.project_id
service_account = var.service_account
Expand Down
1 change: 1 addition & 0 deletions examples/umig/static_ips/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module "instance_template" {
version = "~> 12.0"

project_id = var.project_id
region = var.region
subnetwork = var.subnetwork
subnetwork_project = var.project_id
service_account = var.service_account
Expand Down
4 changes: 2 additions & 2 deletions modules/instance_template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ See the [simple](../../examples/instance_template/simple) for a usage example.
| nic\_type | Valid values are "VIRTIO\_NET", "GVNIC" or set to null to accept API default behavior. | `string` | `null` | no |
| on\_host\_maintenance | Instance availability Policy | `string` | `"MIGRATE"` | no |
| preemptible | Allow the instance to be preempted | `bool` | `false` | no |
| project\_id | The GCP project ID | `string` | `null` | no |
| region | Region where the instance template should be created. | `string` | `null` | no |
| project\_id | The GCP project ID | `string` | n/a | yes |
| region | Region where the instance template should be created. | `string` | n/a | yes |
| resource\_policies | A list of self\_links of resource policies to attach to the instance. Modifying this list will cause the instance to recreate. Currently a max of 1 resource policy is supported. | `list(string)` | `[]` | no |
| 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 = optional(set(string), ["cloud-platform"])<br> })</pre> | n/a | yes |
| shielded\_instance\_config | Not used unless enable\_shielded\_vm is true. Shielded VM configuration for the instance. | <pre>object({<br> enable_secure_boot = bool<br> enable_vtpm = bool<br> enable_integrity_monitoring = bool<br> })</pre> | <pre>{<br> "enable_integrity_monitoring": true,<br> "enable_secure_boot": true,<br> "enable_vtpm": true<br>}</pre> | no |
Expand Down
2 changes: 2 additions & 0 deletions modules/instance_template/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,11 @@ spec:
- name: project_id
description: The GCP project ID
varType: string
required: true
- name: region
description: Region where the instance template should be created.
varType: string
required: true
- name: name_prefix
description: Name prefix for the instance template
varType: string
Expand Down
2 changes: 0 additions & 2 deletions modules/instance_template/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@
variable "project_id" {
type = string
description = "The GCP project ID"
default = null
}

variable "region" {
type = string
description = "Region where the instance template should be created."
default = null
}

variable "name_prefix" {
Expand Down
3 changes: 2 additions & 1 deletion modules/preemptible_and_regular_instance_templates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ See the [simple](../../examples/preemptible_and_regular_instance_templates/simpl
| metadata | Metadata, provided as a map | `map(string)` | `{}` | no |
| name\_prefix | Name prefix for the instance template | `string` | `"default-it"` | no |
| network | The name or self\_link of the network to attach this interface to. Use network attribute for Legacy or Auto subnetted networks and subnetwork for custom subnetted networks. | `string` | `""` | no |
| project\_id | The GCP project ID | `string` | `null` | no |
| project\_id | The GCP project ID | `string` | n/a | yes |
| region | Region where the instance template should be created. | `string` | n/a | yes |
| 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 |
| source\_image | Source disk image. If neither source\_image nor source\_image\_family is specified, defaults to the latest public Rocky Linux 9 optimized for GCP image. | `string` | `""` | no |
| source\_image\_family | Source image family. If neither source\_image nor source\_image\_family is specified, defaults to the latest public Rocky Linux 9 optimized for GCP image. | `string` | `""` | no |
Expand Down
2 changes: 2 additions & 0 deletions modules/preemptible_and_regular_instance_templates/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module "preemptible" {
source = "../../modules/instance_template"
name_prefix = "${var.name_prefix}-preemptible"
project_id = var.project_id
region = var.region
machine_type = var.machine_type
labels = var.labels
metadata = var.metadata
Expand All @@ -48,6 +49,7 @@ module "regular" {
source = "../../modules/instance_template"
name_prefix = "${var.name_prefix}-regular"
project_id = var.project_id
region = var.region
machine_type = var.machine_type
labels = var.labels
metadata = var.metadata
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ spec:
- name: project_id
description: The GCP project ID
varType: string
required: true
- name: region
description: Region where the instance template should be created.
varType: string
required: true
- name: name_prefix
description: Name prefix for the instance template
varType: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
variable "project_id" {
type = string
description = "The GCP project ID"
default = null
}

variable "region" {
type = string
description = "Region where the instance template should be created."
}

variable "name_prefix" {
Expand Down

0 comments on commit 1df13ff

Please sign in to comment.