TIL – 2025-09-18

Lambda ResourceConflictExceptions can sometimes be solved by redeploying the payload

Got this one today while trying to create an alias on a Lambda with a very heavy code payload:

│ Error: creating Lambda Alias (latest-lambda-version-for-snap-start): operation error Lambda: CreateAlias, https response error StatusCode: 409, RequestID: <request_id>, ResourceConflictException: The operation cannot be performed at this time. The resource <lambda_arn> is currently in the following state: 'Failed'. StateReasonCode: 'FunctionError'
│ 
│   with module.lambda.aws_lambda_alias.this["enable_snap_start"],
│   on .terraform/modules/lambda/main.tf line 124, in resource "aws_lambda_alias" "this":
│  124: resource "aws_lambda_alias" "this" {
│ 

I had just deployed a change in the Lambda configuration that took some time to apply so I first assumed that the background process was not entirely finished. However after 10 minutes it was giving me the same error. This Stack Overflow post hypothesized that the cause might be a drastically different payload size (we use a dummy archive to deploy the infra, the actual code deployment happening closer to the source code), but commenters had doubts and we were reaching lunch time so as a last resort before losing my sanity I launched a code deployment. No problem deploying my alias after that.

Terraform for disabling auto updates of the Lambda runtime version

AWS regularly updates the runtime of the language your Lambda is using and that, rather discreetly (I could not to date find a changelog or a release page, instead you need to inspect the INIT_START part of your logs for a change in the runtime ARN). By default, your Lambda function will automatically switch to the newer runtime if available, even if you did not make any configuration changes. However if you have reasons not to want that you can disable auto updates, either in the console or with the aws_lambda_runtime_management_config resource.

resource "aws_lambda_runtime_management_config" "this" {
  function_name     = aws_lambda_function.this.function_name
  update_runtime_on = <"Auto" | "Manual" | "FunctionUpdate"> 
}

Never volunteer to do anything for the co-owners association

It’s never a good idea. You’ll just end up with a lot of trouble to sort out.

References

Written by

×

,

Leave a comment