-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tf
More file actions
32 lines (28 loc) · 1.07 KB
/
Copy pathmain.tf
File metadata and controls
32 lines (28 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
locals {
# Suffix names with a 1-based index only when launching more than one instance,
# so a single instance keeps the clean name the caller asked for.
instance_names = [
for i in range(var.instance_count) :
var.instance_count > 1 ? format("%s-%d", var.name, i + 1) : var.name
]
}
resource "openstack_compute_instance_v2" "this" {
count = var.instance_count
name = local.instance_names[count.index]
flavor_name = var.flavor_name
image_name = var.image_name
key_pair = var.key_pair_name != "" ? var.key_pair_name : null
security_groups = var.security_group_names
availability_zone = var.availability_zone != "" ? var.availability_zone : null
metadata = var.metadata
user_data = var.user_data != "" ? var.user_data : null
tags = var.tags
network {
uuid = var.network_id
}
lifecycle {
# image_name resolves to an image_id at create time; ignore drift so a
# rebuilt base image elsewhere doesn't force-replace a running instance.
ignore_changes = [image_name]
}
}