Description
This is a re-entry of a previous issue: terraform-aws-modules/terraform-aws-lambda#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.
β οΈ Note
Before you submit an issue, please perform the following first:
- Remove the local
.terraform
directory (! ONLY if state is stored remotely, which hopefully you are following that best practice!): rm -rf .terraform/
- Re-initialize the project root to pull down modules:
terraform init
- Re-attempt your terraform plan or apply and check if the issue still persists
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:
terraform-aws-modules/terraform-aws-lambda#263 (comment)