I’m encountering an error while trying to deploy an AWS Lambda function using Terraform. Although python3.12
is supported by AWS Lambda and works in other projects, I receive the following error:
<code>expected runtime to be one of [nodejs nodejs4.3 nodejs6.10 nodejs8.10 nodejs10.x nodejs12.x nodejs14.x nodejs16.x java8 java8.al2 java11 python2.7 python3.6 python3.7 python3.8 python3.9 dotnetcore1.0 dotnetcore2.0 dotnetcore2.1 dotnetcore3.1 dotnet6 nodejs4.3-edge go1.x ruby2.5 ruby2.7 provided provided.al2 nodejs18.x python3.10 java17 ruby3.2], got python3.12
</code>
<code>expected runtime to be one of [nodejs nodejs4.3 nodejs6.10 nodejs8.10 nodejs10.x nodejs12.x nodejs14.x nodejs16.x java8 java8.al2 java11 python2.7 python3.6 python3.7 python3.8 python3.9 dotnetcore1.0 dotnetcore2.0 dotnetcore2.1 dotnetcore3.1 dotnet6 nodejs4.3-edge go1.x ruby2.5 ruby2.7 provided provided.al2 nodejs18.x python3.10 java17 ruby3.2], got python3.12
</code>
expected runtime to be one of [nodejs nodejs4.3 nodejs6.10 nodejs8.10 nodejs10.x nodejs12.x nodejs14.x nodejs16.x java8 java8.al2 java11 python2.7 python3.6 python3.7 python3.8 python3.9 dotnetcore1.0 dotnetcore2.0 dotnetcore2.1 dotnetcore3.1 dotnet6 nodejs4.3-edge go1.x ruby2.5 ruby2.7 provided provided.al2 nodejs18.x python3.10 java17 ruby3.2], got python3.12
Environment:
- Terraform Version: >=1.x
- AWS Provider Version:
~> 5.6.2
Terraform Configuration:
<code>terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.6.2"
}
}
required_version = ">= 1.8.3"
}
provider "aws" {
region = "us-west-2"
}
resource "aws_lambda_function" "put_data_to_dynamodb" {
filename = data.archive_file.lambda_package.output_path
function_name = "test-lambda"
role = aws_iam_role.lambda_execution_role.arn
handler = "index.lambda_handler"
source_code_hash = data.archive_file.lambda_package.output_base64sha256
runtime = "python3.12"
environment {
variables = {
DYNAMODB_TABLE_NAME = aws_dynamodb_table.security_aggregation_table.name
}
}
}
</code>
<code>terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.6.2"
}
}
required_version = ">= 1.8.3"
}
provider "aws" {
region = "us-west-2"
}
resource "aws_lambda_function" "put_data_to_dynamodb" {
filename = data.archive_file.lambda_package.output_path
function_name = "test-lambda"
role = aws_iam_role.lambda_execution_role.arn
handler = "index.lambda_handler"
source_code_hash = data.archive_file.lambda_package.output_base64sha256
runtime = "python3.12"
environment {
variables = {
DYNAMODB_TABLE_NAME = aws_dynamodb_table.security_aggregation_table.name
}
}
}
</code>
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.6.2"
}
}
required_version = ">= 1.8.3"
}
provider "aws" {
region = "us-west-2"
}
resource "aws_lambda_function" "put_data_to_dynamodb" {
filename = data.archive_file.lambda_package.output_path
function_name = "test-lambda"
role = aws_iam_role.lambda_execution_role.arn
handler = "index.lambda_handler"
source_code_hash = data.archive_file.lambda_package.output_base64sha256
runtime = "python3.12"
environment {
variables = {
DYNAMODB_TABLE_NAME = aws_dynamodb_table.security_aggregation_table.name
}
}
}
Additional Information:
python3.12
works perfectly fine in other projects using a similar configuration.- I have verified that the AWS provider version is correctly specified as
~> 5.6.2
. - I have ensured that the AWS region supports
python3.12
.
What I’ve Tried:
- Upgrading Terraform and AWS Provider: Ensured both are at the latest version.
- Verified AWS Lambda Runtime Availability: Confirmed
python3.12
is supported in my AWS region. - Running
terraform init -upgrade
: Ensured all providers are up-to-date. - Using Other Runtimes: Successfully deployed with
python3.9
andpython3.10
, but need to usepython3.12
.
Despite these steps, I still receive the same error. Any insights or suggestions on resolving this issue would be greatly appreciated.