terraform-aws-lambda icon indicating copy to clipboard operation
terraform-aws-lambda copied to clipboard

Source code changes missed due to InvalidParameterValueException

Open pjungels-paraport opened this issue 11 months ago β€’ 2 comments

Description

Encountering InvalidParameterValueException (and perhaps other exceptions) during terraform apply causes source code changes to be missed. Subsequent successful terraform apply steps continue to miss original code changes.

Versions

  • Module version [Required]: 7.20.2

  • Terraform version: 1.3.8

  • Provider version(s): hashicorp/aws v5.97.0

Reproduction Code [Required]

Steps to reproduce the behavior:

  1. Run terraform apply with Lambda module:
module "lambda_function" {
  source = "terraform-aws-modules/lambda/aws"

  function_name = "my-lambda1"
  handler       = "index.lambda_handler"
  runtime       = "python3.11"

  create_package = true
  source_path = "../src/lambda-function1"
}
  1. In AWS Console, manually edit the Lambda's runtime management configuration: 1) set "Update runtime version" to Manual and 2) supply a version ARN (e.g. arn:aws:lambda:us-east-1::runtime:93841db3a9beab9ac5a6a1822362b2f10a99e5edf5f36ba23aec15e41ff97311)
  2. Modify Lambda function's source code (e.g., add a comment, add a log statement, etc.) and change the runtime in the Terraform to "python3.12"
  3. Run terraform apply. This will fail with message "Error: updating Lambda Function (my-lambda1) configuration: operation error Lambda: UpdateFunctionConfiguration, https response error StatusCode: 400, RequestID: 55289fd5-e9e9-4357-8627-cc046c827ac9, InvalidParameterValueException: Cannot change runtime identifier when runtime management configuration is set to 'Manual'. Change the runtime management configuration to 'Auto' or 'FunctionUpdate', then retry."
  4. In AWS Console, manually edit the Lambda's runtime management configuration: set "Update runtime version" to Auto.
  5. Re-run terraform apply.

Expected behavior

Terraform apply runs successfully, the Lambda's runtime is modified to Python 3.12, and the source code change from step 3 is applied.

Actual behavior

Terraform apply runs successfully and the Lambda's runtime is modified to Python 3.12. However, the source code change from step 3 is NOT applied.

Additional context

Introducing a new code change (which changes the hash) before a subsequent terraform apply will cause the source code to update properly.

pjungels-paraport avatar May 05 '25 18:05 pjungels-paraport

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

github-actions[bot] avatar Jun 05 '25 00:06 github-actions[bot]

Not stale

paul-jungels1 avatar Jun 05 '25 14:06 paul-jungels1

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

github-actions[bot] avatar Jul 06 '25 00:07 github-actions[bot]

This issue was automatically closed because of stale in 10 days

github-actions[bot] avatar Jul 17 '25 00:07 github-actions[bot]

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.

github-actions[bot] avatar Aug 16 '25 02:08 github-actions[bot]