This Issue caught by spinning up the resources using terraform in LOCALSTACK
Creating multiple MSK event source mapping in one lambda function using terraform 'aws_lambda_event_source_mapping' is throwing ResourceConflictException.
The topics and consumer group id are different however the MSK cluster arn is same as the topics are belongs to the same MSK cluster.
Expected Behavior
It should be able to create the MSK event source map for different topics and consumer group
Actual Behavior
It throwing below error when creating second event-source-map
Error: creating Lambda Event Source Mapping (XXXX): operation error Lambda: CreateEventSourceMapping, https response error StatusCode: 409, RequestID: XXXX, ResourceConflictException: The event source arn (" aXXXX ") and function (" mgd-lmda-dp-tenant-event- ") provided mapping already exists. Please update or delete the existing mapping with UUID 79e98ec5-e10a-4962-87fc-8abd3651d177
│
│ with aws_lambda_event_source_mapping.lambda_msk_event_source_mapping,
│ on event-source-mapping.tf line 16, in resource "aws_lambda_event_source_mapping" "lambda_msk_event_source_mapping":
│ 16: resource "aws_lambda_event_source_mapping" "lambda_msk_event_source_mapping" {
Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
Volunteering to Work on This Issue
If you are interested in working on this issue, please leave a comment.
If this would be your first contribution, please review the contribution guide.
Terraform Core Version
1.9.4
AWS Provider Version
5.76.0
Affected Resource(s)
Description:
Expected Behavior
It should be able to create the MSK event source map for different topics and consumer group
Actual Behavior
It throwing below error when creating second event-source-map
Error: creating Lambda Event Source Mapping (XXXX): operation error Lambda: CreateEventSourceMapping, https response error StatusCode: 409, RequestID: XXXX, ResourceConflictException: The event source arn (" aXXXX ") and function (" mgd-lmda-dp-tenant-event- ") provided mapping already exists. Please update or delete the existing mapping with UUID 79e98ec5-e10a-4962-87fc-8abd3651d177 │ │ with aws_lambda_event_source_mapping.lambda_msk_event_source_mapping, │ on event-source-mapping.tf line 16, in resource "aws_lambda_event_source_mapping" "lambda_msk_event_source_mapping": │ 16: resource "aws_lambda_event_source_mapping" "lambda_msk_event_source_mapping" {
Relevant Error/Panic Output Snippet
No response
Terraform Configuration Files
resource "aws_lambda_event_source_mapping" "lambda_msk_event_source_mapping_created" { event_source_arn = var.event_source_arn enabled = var.msk_event_source_enabled function_name = module.managed_lambda_function.lamda_arn topics = ["topic1"] starting_position = "LATEST" amazon_managed_kafka_event_source_config { consumer_group_id = "Provisioner" }
Randomly event source mapping fails if lambda creation takes longer time
depends_on = [module.managed_lambda_function] }
resource "aws_lambda_event_source_mapping" "lambda_msk_event_source_mapping_deleted" { event_source_arn = var.event_source_arn enabled = var.msk_event_source_enabled function_name = module.managed_lambda_function.lamda_arn topics = ["topic2"] starting_position = "LATEST" amazon_managed_kafka_event_source_config { consumer_group_id = "Deleted" }
Randomly event source mapping fails if lambda creation takes longer time
depends_on = [module.managed_lambda_function] }
Steps to Reproduce
Debug Output
No response
Panic Output
No response
Important Factoids
No response
References
No response
Would you like to implement a fix?
None