Skip to content

Commit a53e140

Browse files
authored
feat: Allow IP assignment in instance templates (#118)
1 parent a89a025 commit a53e140

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

examples/compute_instance/disk_snapshot/main.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,16 @@ module "instance_template" {
3636
boot = false
3737
disk_size_gb = 20
3838
disk_type = "pd-standard"
39+
disk_name = null
40+
device_name = null
3941
},
4042
{
4143
auto_delete = true
4244
boot = false
4345
disk_size_gb = 30
4446
disk_type = "pd-standard"
47+
disk_name = null
48+
device_name = null
4549
}
4650
]
4751
}

modules/instance_template/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ unmanaged instance groups submodules.
88

99
See the [simple](../../examples/instance_template/simple) for a usage example.
1010

11-
## Testing
12-
1311
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
1412
## Inputs
1513

@@ -27,6 +25,7 @@ See the [simple](../../examples/instance_template/simple) for a usage example.
2725
| metadata | Metadata, provided as a map | `map(string)` | `{}` | no |
2826
| name\_prefix | Name prefix for the instance template | `string` | `"default-instance-template"` | no |
2927
| 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 |
28+
| network\_ip | Private IP address to assign to the instance if desired. | `string` | `""` | no |
3029
| preemptible | Allow the instance to be preempted | `bool` | `false` | no |
3130
| project\_id | The GCP project ID | `string` | `null` | no |
3231
| region | Region where the instance template should be created. | `string` | `null` | no |

modules/instance_template/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ resource "google_compute_instance_template" "tpl" {
100100
network = var.network
101101
subnetwork = var.subnetwork
102102
subnetwork_project = var.subnetwork_project
103+
network_ip = length(var.network_ip) > 0 ? var.network_ip : null
103104
dynamic "access_config" {
104105
for_each = var.access_config
105106
content {

modules/instance_template/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ variable "subnetwork_project" {
123123
default = ""
124124
}
125125

126+
variable "network_ip" {
127+
description = "Private IP address to assign to the instance if desired."
128+
default = ""
129+
}
130+
126131
###########
127132
# metadata
128133
###########

0 commit comments

Comments
 (0)