outputs.tf 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # Some of this is redundant or not generated from this module, but it's a nice
  2. # centralized place to get all of the data needed to setup the VPN connections.
  3. output vpn_info {
  4. value = [
  5. for index, connection in aws_vpn_connection.vpn:
  6. {
  7. "cgw_public_ip" = var.interconnect_public_ips[index]
  8. "cgw_private_ip" = var.interconnect_private_ips[index]
  9. "cgw_neighbor_ips" = [ for ip in var.interconnect_private_ips: ip if ip != var.interconnect_private_ips[index] ]
  10. "vgw_public_ips" = [
  11. connection.tunnel1_address,
  12. connection.tunnel2_address
  13. ],
  14. "cgw_inside_address" = [
  15. connection.tunnel1_cgw_inside_address,
  16. connection.tunnel2_cgw_inside_address
  17. ],
  18. "vgw_inside_address" = [
  19. connection.tunnel1_vgw_inside_address,
  20. connection.tunnel2_vgw_inside_address
  21. ]
  22. "preshared_key" = [
  23. connection.tunnel1_preshared_key,
  24. connection.tunnel2_preshared_key
  25. ]
  26. "vgw_bgp_asn" = connection.tunnel1_bgp_asn, # Tunnel 1 and 2 are same
  27. "cgw_bgp_asn" = var.interconnect_asn
  28. }
  29. ]
  30. }
  31. output yaml {
  32. # The contents are the same as above, in an environment key
  33. value = yamlencode({
  34. "" = {
  35. (var.aws_partition_alias) = [
  36. for index, connection in aws_vpn_connection.vpn:
  37. {
  38. "cgw_public_ip" = var.interconnect_public_ips[index]
  39. "cgw_private_ip" = var.interconnect_private_ips[index]
  40. "cgw_neighbor_ips" = [ for ip in var.interconnect_private_ips: ip if ip != var.interconnect_private_ips[index] ]
  41. "vgw_public_ips" = [
  42. connection.tunnel1_address,
  43. connection.tunnel2_address
  44. ],
  45. "cgw_inside_address" = [
  46. connection.tunnel1_cgw_inside_address,
  47. connection.tunnel2_cgw_inside_address
  48. ],
  49. "vgw_inside_address" = [
  50. connection.tunnel1_vgw_inside_address,
  51. connection.tunnel2_vgw_inside_address
  52. ]
  53. "preshared_key" = [
  54. connection.tunnel1_preshared_key,
  55. connection.tunnel2_preshared_key
  56. ]
  57. "vgw_bgp_asn" = connection.tunnel1_bgp_asn, # Tunnel 1 and 2 are same
  58. "cgw_bgp_asn" = var.interconnect_asn
  59. }
  60. ]
  61. }
  62. })
  63. }