Maps a self-managed Apache Kafka topic to a Lambda function, including VPC configuration for secure access.

Terraform Template

resource "aws_lambda_event_source_mapping" "example" {
  function_name = "aws_lambda_function.example.arn"

  self_managed_event_source {

    endpoints = {
      KAFKA_BOOTSTRAP_SERVERS = "kafka1.example.com:9092,kafka2.example.com:9092"
    }
  }

  source_access_configuration {
    type = "VPC_SUBNET"
    uri = "subnet:subnet-example1"
  }

  source_access_configuration {
    type = "VPC_SUBNET"
    uri = "subnet:subnet-example2"
  }

  source_access_configuration {
    type = "VPC_SECURITY_GROUP"
    uri = "security_group:sg-example"
  }
  starting_position = "TRIM_HORIZON"
  topics = ["Example"]
}