File tree Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,17 @@ provider "google" {
2121 version = " ~> 2.7.0"
2222}
2323
24+ resource "google_compute_address" "ip_address" {
25+ name = " external-ip"
26+ }
27+
28+ locals {
29+ access_config = {
30+ nat_ip = google_compute_address.ip_address.address
31+ network_tier = " PREMIUM"
32+ }
33+ }
34+
2435module "instance_template" {
2536 source = " ../../../modules/instance_template"
2637 name_prefix = " ${ var . hostname } -instance-template"
@@ -61,4 +72,5 @@ module "umig" {
6172 num_instances = var. target_size
6273 instance_template = module. instance_template . self_link
6374 named_ports = var. named_ports
75+ access_config = [local . access_config ]
6476}
Original file line number Diff line number Diff line change @@ -53,6 +53,14 @@ resource "google_compute_instance_from_template" "compute_instance" {
5353 network_ip = length (var. static_ips ) == 0 ? " " : element (local. static_ips , count. index )
5454 }
5555
56+ dynamic "access_config" {
57+ for_each = var. access_config
58+ content {
59+ nat_ip = access_config. value . nat_ip
60+ network_tier = access_config. value . network_tier
61+ }
62+ }
63+
5664 source_instance_template = var. instance_template
5765}
5866
Original file line number Diff line number Diff line change @@ -64,3 +64,11 @@ variable "instance_template" {
6464 description = " Instance template self_link used to create compute instances"
6565}
6666
67+ variable "access_config" {
68+ description = " Access configurations, i.e. IPs via which the VM instance can be accessed via the Internet."
69+ type = list (object ({
70+ nat_ip = string
71+ network_tier = string
72+ }))
73+ default = []
74+ }
You can’t perform that action at this time.
0 commit comments