Skip to content

Commit 25e4903

Browse files
committed
expose region
1 parent ca3a958 commit 25e4903

File tree

7 files changed

+18
-1
lines changed

7 files changed

+18
-1
lines changed

examples/compute_instance/simple/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,19 @@
1717
provider "google" {
1818

1919
project = var.project_id
20-
region = var.region
2120
version = "~> 2.7.0"
2221
}
2322

2423
module "instance_template" {
2524
source = "../../../modules/instance_template"
25+
region = var.region
2626
subnetwork = var.subnetwork
2727
service_account = var.service_account
2828
}
2929

3030
module "compute_instance" {
3131
source = "../../../modules/compute_instance"
32+
region = var.region
3233
subnetwork = var.subnetwork
3334
num_instances = var.num_instances
3435
hostname = "instance-simple"

modules/compute_instance/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ See the [simple](examples/compute_instance/simple) for a usage example.
1919
| instance\_template | Instance template self_link used to create compute instances | string | n/a | yes |
2020
| network | Network to deploy to. Only one of network or subnetwork should be specified. | string | `""` | no |
2121
| num\_instances | Number of instances to create. This value is ignored if static_ips is provided. | string | `"1"` | no |
22+
| region | Region where the instances should be created. | string | `"null"` | no |
2223
| static\_ips | List of static IPs for VM instances | list(string) | `<list>` | no |
2324
| subnetwork | Subnet to deploy to. Only one of network or subnetwork should be specified. | string | `""` | no |
2425
| subnetwork\_project | The project that subnetwork belongs to | string | `""` | no |

modules/compute_instance/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ locals {
2929
###############
3030

3131
data "google_compute_zones" "available" {
32+
region = var.region
3233
}
3334

3435
#############

modules/compute_instance/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,9 @@ variable "instance_template" {
4949
description = "Instance template self_link used to create compute instances"
5050
}
5151

52+
variable "region" {
53+
type = string
54+
description = "Region where the instances should be created."
55+
default = null
56+
}
57+

modules/instance_template/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ See the [simple](../../examples/instance_template/simple) for a usage example.
2929
| 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 |
3030
| preemptible | Allow the instance to be preempted | bool | `"false"` | no |
3131
| project\_id | The GCP project ID | string | `"null"` | no |
32+
| region | Region where the instance template should be created. | string | `"null"` | no |
3233
| service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account. | object | n/a | yes |
3334
| shielded\_instance\_config | Not used unless enable_shielded_vm is true. Shielded VM configuration for the instance. | object | `<map>` | no |
3435
| source\_image | Source disk image. If neither source_image nor source_image_family is specified, defaults to the latest public CentOS image. | string | `""` | no |

modules/instance_template/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ resource "google_compute_instance_template" "tpl" {
6363
tags = var.tags
6464
can_ip_forward = var.can_ip_forward
6565
metadata_startup_script = var.startup_script
66+
region = var.region
6667
dynamic "disk" {
6768
for_each = local.all_disks
6869
content {

modules/instance_template/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ variable "preemptible" {
5353
default = false
5454
}
5555

56+
variable "region" {
57+
type = string
58+
description = "Region where the instance template should be created."
59+
default = null
60+
}
61+
5662
#######
5763
# disk
5864
#######

0 commit comments

Comments
 (0)