outputs.tf 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. output "name" {
  2. value = aws_security_group.this.name
  3. }
  4. # Sorted "<protocol>/<from>-<to>/<cidr>" descriptors for the any-address
  5. # outbound rules, so tests (and stacks) can pin the exact set. No secrets.
  6. output "outbound_rules" {
  7. value = sort([
  8. for r in aws_vpc_security_group_egress_rule.internet :
  9. "${r.ip_protocol}/${r.from_port}-${r.to_port}/${r.cidr_ipv4}"
  10. ])
  11. }
  12. # Sorted "<protocol>/<from>-<to>/<source group>" descriptors for the inbound rules.
  13. output "inbound_rules" {
  14. value = sort(concat(
  15. [
  16. for r in aws_vpc_security_group_ingress_rule.member :
  17. "${r.ip_protocol}/${r.from_port}-${r.to_port}/${r.referenced_security_group_id}"
  18. ],
  19. [
  20. for r in aws_vpc_security_group_ingress_rule.other_group :
  21. "${r.ip_protocol}/${r.from_port}-${r.to_port}/${r.referenced_security_group_id}"
  22. ],
  23. ))
  24. }
  25. # Sorted descriptors for the outbound rules that reach group members.
  26. output "outbound_member_rules" {
  27. value = sort([
  28. for r in aws_vpc_security_group_egress_rule.member :
  29. "${r.ip_protocol}/${r.from_port}-${r.to_port}/${r.referenced_security_group_id}"
  30. ])
  31. }
  32. # The module contract (design section 5). Same names on every provider; see
  33. # README.md for the role table.
  34. output "id" {
  35. description = "Identifier a stack can depend on."
  36. value = aws_security_group.this.id
  37. # Wait for every rule, not just the group: a machine that launches with this
  38. # group must find its egress rules already in place, or cloud-init's package
  39. # install races them. (UNVERIFIED ordering until an apply.)
  40. depends_on = [
  41. aws_vpc_security_group_ingress_rule.member,
  42. aws_vpc_security_group_ingress_rule.other_group,
  43. aws_vpc_security_group_egress_rule.internet,
  44. aws_vpc_security_group_egress_rule.member,
  45. ]
  46. }
  47. # What the rules attach to. On AWS this is the security group a machine lists
  48. # in vpc_security_group_ids when it launches.
  49. output "rule_targets" {
  50. value = [aws_security_group.this.id]
  51. # Wait for every rule, not just the group: a machine that launches with this
  52. # group must find its egress rules already in place, or cloud-init's package
  53. # install races them. (UNVERIFIED ordering until an apply.)
  54. depends_on = [
  55. aws_vpc_security_group_ingress_rule.member,
  56. aws_vpc_security_group_ingress_rule.other_group,
  57. aws_vpc_security_group_egress_rule.internet,
  58. aws_vpc_security_group_egress_rule.member,
  59. ]
  60. }
  61. # Who may reach the targets by membership rather than by address. Here: the
  62. # security groups named as the source of an inbound rule (this group itself and
  63. # any other group from inbound_from_other_groups).
  64. output "source_members" {
  65. value = sort(distinct(concat(
  66. [for r in aws_vpc_security_group_ingress_rule.member : r.referenced_security_group_id],
  67. [for r in aws_vpc_security_group_ingress_rule.other_group : r.referenced_security_group_id],
  68. )))
  69. }
  70. # What the targets may reach by membership. Here: the security groups named as
  71. # the destination of an outbound rule (this group itself).
  72. output "destination_members" {
  73. value = sort(distinct([for r in aws_vpc_security_group_egress_rule.member : r.referenced_security_group_id]))
  74. }