hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.85k stars 9.2k forks source link

[Bug]: Error: creating Lambda Event Source Mapping operation error Lambda: CreateEventSourceMapping, https response error StatusCode: 409, RequestID: XXXXX, ResourceConflictException: The event source arn provided mapping already exists. Please update or delete the existing mapping with UUID #40257

Open Adarsha-1994 opened 7 hours ago

Adarsha-1994 commented 7 hours ago

Terraform Core Version

1.9.4

AWS Provider Version

5.76.0

Affected Resource(s)

Description:

  1. This Issue caught by spinning up the resources using terraform in LOCALSTACK
  2. Creating multiple MSK event source mapping in one lambda function using terraform 'aws_lambda_event_source_mapping' is throwing ResourceConflictException.
  3. 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" {

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] }

Screenshot 2024-11-22 at 3 49 43 PM

Steps to Reproduce

  1. Setup localstack - 3.8.1 version
  2. create a lambda function along with multiple event-source-map using terraform
  3. run terraform init
  4. run terraform plan
  5. run terraform apply (you will be able to reproduce the issue when applied)

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 7 hours ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue