Search code examples
amazon-web-servicesapache-kafkalambdaterraform

Unsupported self_managed_kafka_event_source_config block type in terraform


I’m trying to create an AWS Lambda event source mapping for a self-managed Kafka cluster using the aws_lambda_event_source_mapping resource. However, I’m encountering the following error:

Error: Unsupported block type

  on ../../modules/lambda/main.tf line 87, in resource "aws_lambda_event_source_mapping" "horizon":
  87:   self_managed_kafka_event_source_config {

Blocks of type "self_managed_kafka_event_source_config" are not expected here.

I’m currently using Terraform v1.5.7 in Linux.

Here’s a snippet of my configuration:

resource "aws_lambda_event_source_mapping" "horizon" {
  function_name     = aws_lambda_function.kafka_consumer_identity.arn
  topics            = [var.kafka_topics]
  starting_position = "TRIM_HORIZON"
  batch_size = 10

  self_managed_event_source {
    endpoints = {
      KAFKA_BOOTSTRAP_SERVERS = var.kafka_bootstrap_servers
    }
  }

  self_managed_kafka_event_source_config {
    consumer_group_id = var.consumer_group_id
  }

  source_access_configuration {
    type = "BASIC_AUTH"
    uri  = var.secret_manager_key_arn
  }

  source_access_configuration {
    type = "VPC_SUBNET"
    uri  = var.vpc_subnet_1
  }

  source_access_configuration {
    type = "VPC_SUBNET"
    uri  = var.vpc_subnet_2
  }

  source_access_configuration {
    type = "VPC_SUBNET"
    uri  = var.vpc_subnet_3
  }

  source_access_configuration {
    type = "VPC_SECURITY_GROUP"
    uri  = var.vpc_security_group
  }
}

Is self_managed_kafka_event_source_config a valid block within aws_lambda_event_source_mapping? Has there been a recent change, or am I missing something in my configuration?

Any help would be greatly appreciated!

Thank you!

I tried removing the block self_managed_kafka_event_source_config and it worked fine. However, I need to supply the consumer_group_id as an argument for this data source.


Solution

  • You have to upgrade your AWS provider to the newest one which is 5.18.1. You are using old one, which has no support for self_managed_kafka_event_source_config.