Skip to content

Commit cfc281e

Browse files
authored
Merge pull request #57 from omazin/umig-external-ip
[umig] Add external ips support.
2 parents 48a9b07 + 3e2798b commit cfc281e

File tree

5 files changed

+40
-4
lines changed

5 files changed

+40
-4
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this
66
project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
9+
10+
### Added
11+
12+
- `access_config` variable on the `umig` submodule. [#57]
13+
14+
915
## [1.3.0] - 2019-12-09
1016

1117
### Added
@@ -16,7 +22,7 @@ project adheres to [Semantic Versioning](http://semver.org/).
1622

1723
### Added
1824

19-
- Support for public IPs. Added `access_config` variable. [#43]
25+
- `access_config` variable on the `instance_template` and `preemptible_and_regular_instance_templates` submodules. [#43]
2026

2127
### Fixed
2228

@@ -77,3 +83,4 @@ project adheres to [Semantic Versioning](http://semver.org/).
7783
[#42]: https://github.com/terraform-google-modules/terraform-google-vm/pull/42
7884
[#43]: https://github.com/terraform-google-modules/terraform-google-vm/pull/43
7985
[#44]: https://github.com/terraform-google-modules/terraform-google-vm/pull/44
86+
[#57]: https://github.com/terraform-google-modules/terraform-google-vm/pull/57

examples/umig/full/main.tf

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2018 Google LLC
2+
* Copyright 2019 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -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+
2435
module "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
}

modules/umig/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ See the [simple](examples/umig/simple) for a usage example.
1515

1616
| Name | Description | Type | Default | Required |
1717
|------|-------------|:----:|:-----:|:-----:|
18+
| access\_config | Access configurations, i.e. IPs via which the VM instance can be accessed via the Internet. | object | `<list>` | no |
1819
| hostname | Hostname of instances | string | `""` | no |
1920
| instance\_template | Instance template self_link used to create compute instances | string | n/a | yes |
2021
| named\_ports | Named name and named port | object | `<list>` | no |

modules/umig/main.tf

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2018 Google LLC
2+
* Copyright 2019 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -51,6 +51,14 @@ resource "google_compute_instance_from_template" "compute_instance" {
5151
subnetwork = var.subnetwork
5252
subnetwork_project = var.subnetwork_project
5353
network_ip = length(var.static_ips) == 0 ? "" : element(local.static_ips, count.index)
54+
55+
dynamic "access_config" {
56+
for_each = var.access_config
57+
content {
58+
nat_ip = access_config.value.nat_ip
59+
network_tier = access_config.value.network_tier
60+
}
61+
}
5462
}
5563

5664
source_instance_template = var.instance_template

modules/umig/variables.tf

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2018 Google LLC
2+
* Copyright 2019 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -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+
}

0 commit comments

Comments
 (0)