Source code changes missed due to InvalidParameterValueException
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:
- 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"
}
- 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)
- 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"
- 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."
- In AWS Console, manually edit the Lambda's runtime management configuration: set "Update runtime version" to Auto.
- 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.
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
Not stale
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.