What resources do I need to set up to create a schedule which will push message to a SQS queue with body specified within terraform?
I found this https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_event_rule but I can't see a field which would let me input body of message.
How I imagine this:
resource "aws_cloudwatch_something" "sheduled_event" {
sqs_arn =
event_body =
cron_expression =
}
It would push event_body
to sqs_arn
queue every cron_expression
.
Is it achievable in terraform?
CodePudding user response:
You need to associate an event rule with an event target. However, the SQS target doesn't allow you to specify body content; it will always receive the body of the event.
I think a better approach (although more complex) is to introduce a Lambda: the EventBridge rule triggers the Lambda, which writes a message to the queue.