main.tf 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # Panorama
  2. resource "aws_placement_group" "panorama_group" {
  3. name = "Panorama Placement Group"
  4. strategy = "spread"
  5. }
  6. resource "aws_instance" "panorama" {
  7. count = var.panorama_count
  8. ami = lookup(var.panorama_ami, var.aws_region)
  9. availability_zone = var.azs[count.index % 2]
  10. placement_group = aws_placement_group.panorama_group.id
  11. tenancy = "default"
  12. ebs_optimized = true
  13. disable_api_termination = var.instance_termination_protection
  14. instance_initiated_shutdown_behavior = "stop"
  15. instance_type = var.panorama_instance_type
  16. key_name = var.panorama_key_name
  17. monitoring = false
  18. vpc_security_group_ids = var.panorama_security_group_ids
  19. subnet_id = var.subnet_id_map["management"][count.index % 2]
  20. #associate_public_ip_address = true # causes a recreate on apply if you set this!
  21. private_ip = cidrhost(var.subnet_cidr_map["management"][count.index % 2], 5 + (count.index % 2))
  22. source_dest_check = true
  23. tags = merge(
  24. var.standard_tags,
  25. var.tags,
  26. { Name = "xdr-panorama-${count.index}" }
  27. )
  28. root_block_device {
  29. volume_type = "gp2"
  30. volume_size = "81"
  31. delete_on_termination = true
  32. encrypted = true
  33. kms_key_id = var.ebs_key
  34. }
  35. # The provisioner doesn't do anything
  36. #connection {
  37. # type = "ssh"
  38. # user = "admin"
  39. # private_key = file("~/.ssh/id_rsa") # Use your private key
  40. # host = aws_eip.management_eip[count.index].public_ip
  41. #}
  42. #
  43. #provisioner "remote-exec" {
  44. # # Used by a provisioner
  45. #
  46. # inline = [
  47. # "set mgt-config users admin password",
  48. # "testme",
  49. # "testme",
  50. # "commit"
  51. # ]
  52. # on_failure = continue
  53. #}
  54. }
  55. # EIP for Management Interface, declared separately so they're easier to preserve
  56. resource "aws_eip" "management_eip" {
  57. count = var.panorama_count
  58. vpc = true
  59. }
  60. resource "aws_eip_association" "eip_assoc" {
  61. count = var.panorama_count
  62. instance_id = aws_instance.panorama[count.index].id
  63. allocation_id = aws_eip.management_eip[count.index].id
  64. private_ip_address = cidrhost(var.subnet_cidr_map["management"][count.index % 2], 5 + (count.index % 2))
  65. }