ec2.tf 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. data aws_ami "preauthorized" {
  2. most_recent = true
  3. owners = ["aws-marketplace"]
  4. filter {
  5. name = "product-code"
  6. values = [ "1mp9h4zd2ze4biqif5schqeyu" ]
  7. }
  8. filter {
  9. name = "name"
  10. values = [ "qVSA*" ]
  11. }
  12. }
  13. data aws_ami "standard" {
  14. most_recent = true
  15. owners = ["aws-marketplace"]
  16. filter {
  17. name = "product-code"
  18. values = [ "9hnn1m0a6jb7k2r1n9itk3jxu" ]
  19. }
  20. filter {
  21. name = "name"
  22. values = [ "qVSA*" ]
  23. }
  24. }
  25. # Use the default EBS key
  26. data "aws_kms_key" "ebs-key" {
  27. key_id = "alias/ebs_root_encrypt_decrypt"
  28. }
  29. resource aws_instance "qualys_scanner_preauthorized" {
  30. count = var.create_preauthorized_scanner == true ? 1 : 0
  31. ami = data.aws_ami.preauthorized.id
  32. instance_type = "t3.medium"
  33. subnet_id = var.subnets[0]
  34. user_data = base64encode("PERSCODE=${var.personalization_codes["preauthorized"]}%{ if var.proxy!="" }\nPROXY_URL=${var.proxy}:80%{ endif }")
  35. key_name = "msoc-build"
  36. ebs_optimized = true
  37. vpc_security_group_ids = [
  38. module.qualys_scanner_sg.security_group_id
  39. ]
  40. credit_specification {
  41. cpu_credits = "unlimited"
  42. }
  43. tags = merge(var.standard_tags,var.tags,{"Name": "qualys-scanner-preauthorized"})
  44. volume_tags = merge(var.standard_tags,var.tags,{"Name": "qualys-scanner-preauthorized"})
  45. root_block_device {
  46. volume_size = 100
  47. volume_type = "gp2"
  48. encrypted = true
  49. kms_key_id = data.aws_kms_key.ebs-key.arn
  50. }
  51. lifecycle {
  52. ignore_changes = [ ami ]
  53. }
  54. }
  55. resource aws_instance "qualys_scanner_standard" {
  56. count = var.create_standard_scanner == true ? 1 : 0
  57. ami = data.aws_ami.standard.id
  58. instance_type = "t3.medium"
  59. subnet_id = var.subnets[0]
  60. key_name = "msoc-build"
  61. user_data = base64encode("PERSCODE=${var.personalization_codes["standard"]}%{ if var.proxy!="" }\nPROXY_URL=${var.proxy}:80%{ endif }")
  62. ebs_optimized = true
  63. vpc_security_group_ids = [
  64. module.qualys_scanner_sg.security_group_id
  65. ]
  66. credit_specification {
  67. cpu_credits = "unlimited"
  68. }
  69. tags = merge(var.standard_tags,var.tags,{"Name": "qualys-scanner-standard"})
  70. volume_tags = merge(var.standard_tags,var.tags,{"Name": "qualys-scanner-standard"})
  71. root_block_device {
  72. volume_size = 100
  73. volume_type = "gp2"
  74. encrypted = true
  75. kms_key_id = data.aws_kms_key.ebs-key.arn
  76. }
  77. lifecycle {
  78. ignore_changes = [ ami ]
  79. }
  80. }
  81. module "private_dns_record_preauthorized" {
  82. source = "../../submodules/dns/private_A_record"
  83. count = var.create_preauthorized_scanner == true ? 1 : 0
  84. name = "qualys-preauthorized"
  85. ip_addresses = [ aws_instance.qualys_scanner_preauthorized[count.index].private_ip ]
  86. dns_info = var.dns_info
  87. reverse_enabled = var.reverse_enabled
  88. providers = {
  89. aws.c2 = aws.c2
  90. }
  91. }
  92. module "private_dns_record_standard" {
  93. source = "../../submodules/dns/private_A_record"
  94. count = var.create_standard_scanner == true ? 1 : 0
  95. name = "qualys-standard"
  96. ip_addresses = [ aws_instance.qualys_scanner_standard[count.index].private_ip ]
  97. dns_info = var.dns_info
  98. reverse_enabled = var.reverse_enabled
  99. providers = {
  100. aws.c2 = aws.c2
  101. }
  102. }