sqs.tf 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #### SQS Queues for Analysis
  2. resource "aws_sqs_queue" "fcm-analysis-EbsEncryptionByDefault-deadletter" {
  3. name = "fcm-analysis-EbsEncryptionByDefault-deadletter"
  4. visibility_timeout_seconds = 5400 # How long before the item can be retried if something went wrong, should match processing time. Should be at least 6 times the lambda timeout
  5. delay_seconds = 0 # Delay before message is delivered. This can be increased if resources take longer to be active.
  6. max_message_size = 262144 # How big messages can get. 256KB is the max for SNS and SQS
  7. message_retention_seconds = 1209600 # Better handle it with 14 days!
  8. kms_master_key_id = "alias/fcm"
  9. depends_on = [aws_kms_alias.FCM-Key]
  10. kms_data_key_reuse_period_seconds = 300 # keep using the same data key for up to 5 minutes
  11. tags = {
  12. Project = "FredsCloudMonitor"
  13. }
  14. }
  15. resource "aws_sqs_queue" "fcm-analysis-EbsEncryptionByDefault" {
  16. name = "fcm-analysis-EbsEncryptionByDefault"
  17. visibility_timeout_seconds = 900 # How long before the item can be retried if something went wrong, should match processing time
  18. delay_seconds = 0 # Delay before message is delivered. This can be increased if resources take longer to be active.
  19. max_message_size = 262144 # How big messages can get. 256KB is the max for SNS and SQS
  20. message_retention_seconds = 86400 # How long to keep the message
  21. redrive_policy = "{\"deadLetterTargetArn\":\"${aws_sqs_queue.fcm-analysis-EbsEncryptionByDefault-deadletter.arn}\",\"maxReceiveCount\":4}" # maxReceiveCount is how many times to attempt processing
  22. kms_master_key_id = "alias/fcm"
  23. depends_on = [aws_kms_alias.FCM-Key]
  24. kms_data_key_reuse_period_seconds = 300 # keep using the same data key for up to 5 minutes
  25. tags = {
  26. Project = "FredsCloudMonitor"
  27. }
  28. }
  29. resource "aws_sqs_queue_policy" "fcm-analysis-EbsEncryptionByDefault" {
  30. queue_url = "${aws_sqs_queue.fcm-analysis-EbsEncryptionByDefault.id}"
  31. policy = <<POLICY
  32. {
  33. "Version": "2012-10-17",
  34. "Id": "sqspolicy",
  35. "Statement": [
  36. {
  37. "Sid": "SNSPermissions",
  38. "Effect": "Allow",
  39. "Principal": "*",
  40. "Action": "sqs:SendMessage",
  41. "Resource": "${aws_sqs_queue.fcm-analysis-EbsEncryptionByDefault.arn}",
  42. "Condition": {
  43. "ArnEquals": {
  44. "aws:SourceArn": [
  45. "${aws_sns_topic.fcm-input-DisableEbsEncryptionByDefault.arn}",
  46. "${aws_sns_topic.fcm-input-EnableEbsEncryptionByDefault.arn}",
  47. "${aws_sns_topic.fcm-custom-EbsEncryptionByDefault.arn}"
  48. ]
  49. }
  50. }
  51. }
  52. ]
  53. }
  54. POLICY
  55. }
  56. resource "aws_sns_topic_subscription" "fcm-analysis-EbsEncryptionByDefault1" {
  57. topic_arn = "${aws_sns_topic.fcm-input-DisableEbsEncryptionByDefault.arn}"
  58. protocol = "sqs"
  59. endpoint = "${aws_sqs_queue.fcm-analysis-EbsEncryptionByDefault.arn}"
  60. raw_message_delivery = true # don't add extra sns metadata
  61. }
  62. resource "aws_sns_topic_subscription" "fcm-analysis-EbsEncryptionByDefault2" {
  63. topic_arn = "${aws_sns_topic.fcm-input-EnableEbsEncryptionByDefault.arn}"
  64. protocol = "sqs"
  65. endpoint = "${aws_sqs_queue.fcm-analysis-EbsEncryptionByDefault.arn}"
  66. raw_message_delivery = true # don't add extra sns metadata
  67. }
  68. resource "aws_sns_topic_subscription" "fcm-analysis-EbsEncryptionByDefault3" {
  69. topic_arn = "${aws_sns_topic.fcm-custom-EbsEncryptionByDefault.arn}"
  70. protocol = "sqs"
  71. endpoint = "${aws_sqs_queue.fcm-analysis-EbsEncryptionByDefault.arn}"
  72. raw_message_delivery = true # don't add extra sns metadata
  73. }
  74. #### SQS Queues for Remediation
  75. resource "aws_sqs_queue" "fcm-remediation-EbsEncryptionByDefault-deadletter" {
  76. name = "fcm-remediation-EbsEncryptionByDefault-deadletter"
  77. visibility_timeout_seconds = 5400 # How long before the item can be retried if something went wrong, should match processing time. Should be at least 6 times the lambda timeout
  78. delay_seconds = 0 # Delay before message is delivered. This can be increased if resources take longer to be active.
  79. max_message_size = 262144 # How big messages can get. 256KB is the max for SNS and SQS
  80. message_retention_seconds = 1209600 # Better handle it with 14 days!
  81. kms_master_key_id = "alias/fcm"
  82. depends_on = [aws_kms_alias.FCM-Key]
  83. kms_data_key_reuse_period_seconds = 300 # keep using the same data key for up to 5 minutes
  84. tags = {
  85. Project = "FredsCloudMonitor"
  86. }
  87. }
  88. resource "aws_sqs_queue" "fcm-remediation-EbsEncryptionByDefault" {
  89. name = "fcm-remediation-EbsEncryptionByDefault"
  90. visibility_timeout_seconds = 900 # How long before the item can be retried if something went wrong, should match processing time
  91. delay_seconds = 0 # Delay before message is delivered. This can be increased if resources take longer to be active.
  92. max_message_size = 262144 # How big messages can get. 256KB is the max for SNS and SQS
  93. message_retention_seconds = 86400 # How long to keep the message
  94. redrive_policy = "{\"deadLetterTargetArn\":\"${aws_sqs_queue.fcm-remediation-EbsEncryptionByDefault-deadletter.arn}\",\"maxReceiveCount\":4}" # maxReceiveCount is how many times to attempt processing
  95. kms_master_key_id = "alias/fcm"
  96. depends_on = [aws_kms_alias.FCM-Key]
  97. kms_data_key_reuse_period_seconds = 300 # keep using the same data key for up to 5 minutes
  98. tags = {
  99. Project = "FredsCloudMonitor"
  100. }
  101. }
  102. resource "aws_sqs_queue_policy" "fcm-remediation-EbsEncryptionByDefault" {
  103. queue_url = "${aws_sqs_queue.fcm-remediation-EbsEncryptionByDefault.id}"
  104. policy = <<POLICY
  105. {
  106. "Version": "2012-10-17",
  107. "Id": "sqspolicy",
  108. "Statement": [
  109. {
  110. "Sid": "AllowAnalysisToSend",
  111. "Effect": "Allow",
  112. "Principal": {
  113. "AWS": "${aws_iam_role.fcm-lambda-analysis-EbsEncryptionByDefault.arn}"
  114. },
  115. "Action": "sqs:SendMessage",
  116. "Resource": "${aws_sqs_queue.fcm-remediation-EbsEncryptionByDefault.arn}"
  117. }
  118. ]
  119. }
  120. POLICY
  121. }