# 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]) } } }