-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathdefault_security_group.tf
More file actions
46 lines (40 loc) · 1.32 KB
/
default_security_group.tf
File metadata and controls
46 lines (40 loc) · 1.32 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
##############################################################################
# Update default security group
##############################################################################
locals {
# Convert to object
security_group_rule_object = {
for rule in var.security_group_rules :
rule.name => rule
}
}
resource "ibm_is_security_group_rule" "default_vpc_rule" {
for_each = local.security_group_rule_object
group = var.create_vpc == true ? ibm_is_vpc.vpc[0].default_security_group : data.ibm_is_vpc.vpc.default_security_group
direction = each.value.direction
remote = each.value.remote
local = each.value.local
ip_version = each.value.ip_version
dynamic "tcp" {
for_each = each.value.tcp == null ? [] : [each.value]
content {
port_min = each.value.tcp.port_min
port_max = each.value.tcp.port_max
}
}
dynamic "udp" {
for_each = each.value.udp == null ? [] : [each.value]
content {
port_min = each.value.udp.port_min
port_max = each.value.udp.port_max
}
}
dynamic "icmp" {
for_each = each.value.icmp == null ? [] : [each.value]
content {
type = lookup(each.value.icmp, "type", null)
code = lookup(each.value.icmp, "code", null)
}
}
}
##############################################################################