-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
67 lines (62 loc) · 2.73 KB
/
main.tf
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
##############################################################################
# Create map of total virtual servers for deployment
##############################################################################
locals {
vsi_list = flatten([
# For each subnet in the list. Use range to prevent error for values
# not known until after apply
for subnet in range(length(var.subnet_zone_list)) :
[
# For number of deployments
for instance in range(var.vsi_per_subnet) :
{
name = "${var.deployment_name}-${(subnet) * (var.vsi_per_subnet) + instance + 1}"
zone = var.subnet_zone_list[subnet].zone
primary_subnet_id = var.subnet_zone_list[subnet].id
}
]
])
}
##############################################################################
##############################################################################
# Create Baremetals
##############################################################################
module "baremetal" {
for_each = {
for instance in local.vsi_list :
(instance.name) => instance
}
source = "github.com/terraform-ibm-modules/icse-baremetal-on-vpc"
zone = each.value.zone
primary_subnet_id = each.value.primary_subnet_id
name = each.value.name
prefix = var.prefix
tags = var.tags
resource_group_id = var.resource_group_id
vpc_id = var.vpc_id
primary_allowed_vlans = var.primary_allowed_vlans
primary_enable_infrastructure_nat = var.primary_enable_infrastructure_nat
image_id = var.image_id
profile = var.profile
ssh_key_ids = var.ssh_key_ids
boot_volume_name = var.boot_volume_name
user_data = var.user_data
allow_ip_spoofing = var.allow_ip_spoofing
add_floating_ip = var.add_floating_ip
primary_security_group_ids = (
# If both sg ids and not create sg
var.primary_security_group_ids == null && var.primary_interface_security_group.create != true
# null
? null
# if no ids provided and create is true
: var.primary_security_group_ids == null
# list with only created sg id
? [module.primary_network_security_group[0].groups[0].id]
# otherwise combine lists
: concat(
var.primary_interface_security_group.create == true ? [module.primary_network_security_group[0].groups[0].id] : [],
var.primary_security_group_ids
)
)
}
##############################################################################