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
|
# Outputs ======================================================================
output "vpc_id" {
description = "VPC ID security groups were created in"
value = var.vpc_id
}
output "ids" {
description = "Map of security group logical key to ID"
value = { for k, v in aws_security_group.this : k => v.id }
}
output "arns" {
description = "Map of security group logical key to ARN"
value = { for k, v in aws_security_group.this : k => v.arn }
}
output "names" {
description = "Map of security group logical key to name"
value = { for k, v in aws_security_group.this : k => v.name }
}
output "id_list" {
description = "Flat list of all security group IDs, for use in security_groups/vpc_security_group_ids arguments"
value = values({ for k, v in aws_security_group.this : k => v.id })
}
output "arn_list" {
description = "Flat list of all security group ARNs"
value = values({ for k, v in aws_security_group.this : k => v.arn })
}
output "ingress_rule_ids" {
description = "Map of ingress rule key (sg_key-ingress-idx-source_type-i) to security group rule ID"
value = { for k, v in aws_vpc_security_group_ingress_rule.this : k => v.security_group_rule_id }
}
output "egress_rule_ids" {
description = "Map of egress rule key (sg_key-egress-idx-source_type-i) to security group rule ID"
value = { for k, v in aws_vpc_security_group_egress_rule.this : k => v.security_group_rule_id }
}
output "rule_counts" {
description = "Map of security group logical key to its actual ingress/egress resource counts after expanding multi-source rules, for validating expected rules landed"
value = {
for sg_key, sg in var.security_groups :
sg_key => {
ingress = length([for k, v in local.ingress_rule_map : k if v.sg_key == sg_key])
egress = length([for k, v in local.egress_rule_map : k if v.sg_key == sg_key])
}
}
}
|