// --------------------------------------------------------------------------- // ----------------================ MESSAGING ================---------------- // --------------------------------------------------------------------------- // Ingress Queue resource "aws_sqs_queue" "ingress" { name = var.ingress_queue_name } // Egress event bus resource "aws_cloudwatch_event_bus" "egress" { name = var.egress_bus_name } // Create a rule that routes all logs to cloudwatch for debugging resource "aws_cloudwatch_event_rule" "route_all_cloudwatch" { name = "route-all-cloudwatch" description = "route a copy of all messages to cloudwatch for logging" event_bus_name = aws_cloudwatch_event_bus.egress.name event_pattern = "{ \"account\": [\"${data.aws_caller_identity.current.account_id}\"] }" } resource "aws_cloudwatch_log_group" "egress" { name = "/aws/events/${var.egress_bus_name}" retention_in_days = 1 } resource "aws_cloudwatch_event_target" "cloudwatch" { event_bus_name = aws_cloudwatch_event_bus.egress.name rule = aws_cloudwatch_event_rule.route_all_cloudwatch.name arn = aws_cloudwatch_log_group.egress.arn } // --------------------------------------------------------------------------- // Service A // --------------------------------------------------------------------------- resource "aws_sqs_queue" "service_a" { name = "service-a" } resource "aws_cloudwatch_event_rule" "service_a" { name = "route-service-a" description = "route notifications to service-a target queue" event_bus_name = aws_cloudwatch_event_bus.egress.name event_pattern = <