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

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay