ResourceConflictException: concurrent updates during Lambda creation
agfunderburg10 opened this issue · 3 comments
Description
This is a re-entry of a previous issue: #263 (comment)
The original issue still exists, and I would like to submit the suggested fix.
The resource "aws_lambda_function_event_invoke_config" "this" gets fired twice, in quick and consecutive order, and, for our setup, leads to issues with concurrent updates on the Lambda.
- ✋ I have searched the open/closed issues and my issue is not listed.
Versions
Terraform v1.3.7
on darwin_arm64
provider registry.terraform.io/hashicorp/aws v4.54.0
provider registry.terraform.io/hashicorp/external v2.2.3
provider registry.terraform.io/hashicorp/local v2.3.0
provider registry.terraform.io/hashicorp/null v3.2.1
Module: terraform-aws-modules/lambda/aws
Reproduction Code [Required]
-
We have a main.tf that makes calls to the same (custom) module, three times.
-
Our custom module calls terraform-aws-modules/lambda/aws and configures it with create_async_event_config = true, which is sufficient for the defaults in the variables.tf to come into play and trigger a call of aws_lambda_function_event_invoke_config.
-
This resource, aws_lambda_function_event_invoke_config, will use locals.qualifiers to make two calls via a for_each, in quick succession, once for current_version and once for unqualified_alias.
-
This leads to the following error message, printed:
│ Error: error putting Lambda Function Event Invoke Config (tracking-enrichment-stage-search-enriched-to-aurora:$LATEST): ResourceConflictException: The EventInvokeConfig for function arn:aws:lambda:eu-central-1:<ACCOUNT_ID>:function:tracking-enrichment-stage-search-enriched-to-aurora:$LATEST could not be updated due to a concurrent update operation.
│ {
│ RespMetadata: {
│ StatusCode: 409,
│ RequestID: "6768fc9b-15b2-4fc2-ab60-bbb836d617d4"
│ },
│ Message_: "The EventInvokeConfig for function arn:aws:lambda:eu-central-1:<ACCOUNT_ID>:function:tracking-enrichment-stage-search-enriched-to-aurora:$LATEST could not be updated due to a concurrent update operation.",
│ Type: "User"
│ }
│
│ with module.search_enriched_to_aurora.module.lambda_enriched_to_aurora.aws_lambda_function_event_invoke_config.this["current_version"],
│ on .terraform/modules/search_enriched_to_aurora.lambda_enriched_to_aurora/main.tf line 166, in resource "aws_lambda_function_event_invoke_config" "this":
│ 166: resource "aws_lambda_function_event_invoke_config" "this" {
Expected behavior
The calls should be made in an order that doesn't cause concurrent updates.
Actual behavior
The same Lambda is modified twice, at the same time.
Additional context
A previous suggested fix was discussed here:
#263 (comment)
This issue has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this issue will be closed in 10 days
This issue was automatically closed because of stale in 10 days
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.