DEV Community

Cover image for ActiveMQ as event source for Lambda in Terraform
Vignesh
Vignesh

Posted on

ActiveMQ as event source for Lambda in Terraform

Finding example for ActiveMQ as event source of lambda in terraform is difficult. Here are the steps to setup quickly.

Assuming below services up and running

  1. ActiveMQ broker created with users
  2. Lambda

Step 1:

Create secret(String) in secret manager with below format.

{
    "username": "lambda-sink",
    "password": "random-string"
}
Enter fullscreen mode Exit fullscreen mode

Step 2:

Create below terraform resource

resource "aws_lambda_event_source_mapping" "lambda_sink_mapping" {

  event_source_arn = aws_mq_broker.broker.arn
  function_name    = aws_lambda_function.lambda.function_name
  batch_size       = 100
  queues = ["queue-name"]

  source_access_configuration {
    type = "BASIC_AUTH"
    uri  = aws_secretsmanager_secret.lambda_user_secret.arn
  }
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Heroku

Tired of jumping between terminals, dashboards, and code?

Check out this demo showcasing how tools like Cursor can connect to Heroku through the MCP, letting you trigger actions like deployments, scaling, or provisioning—all without leaving your editor.

Learn More