I'm having an issue creating two lambda functions. My "controller" function deploys with no issue but my "chunker" function throws an error "Error: At least one field is expected inside environment"
Both functions are nearly identical, with differing zip files and environment variables.
function_name = format("ancb-chunker-%s",var.env)
s3_bucket = aws_s3_bucket.ancb["lambda"].id
s3_key = var.lambda_zip_chunker
handler = "handler.chunker"
runtime = "nodejs8.10"
role = aws_iam_role.lambda_exec.arn
environment {
variables = {
TEST = "yes"
ORIGINAL_BUCKET = aws_s3_bucket.ancb["original"].id
TO_PROCESS_BUCKET = aws_s3_bucket.ancb["to-process-prod"].id
ENVIRONMENT = var.env
CHUNK_SIZE = 5000
}
}
tags = {
Environment = var.env
Terraform = true
}
}
resource "aws_lambda_function" "ancb_controller" {
function_name = format("ancb-controller-%s",var.env)
s3_bucket = aws_s3_bucket.ancb["lambda"].id
s3_key = var.lambda_zip_controller
handler = "handler.controller"
runtime = "nodejs8.10"
role = aws_iam_role.lambda_exec.arn
environment {
variables = {
DESTINATION_BUCKET = aws_s3_bucket.ancb["destination"].id
ENVIRONMENT = var.env
ERROR_BUCKET = aws_s3_bucket.ancb["error"].id
GEOCODIO_APIKEY = <removed>
GEOCODIO_ENDPOINT = <removed>
GEOCODIO_VERSION = "v1.3"
ORIGINAL_BUCKET = aws_s3_bucket.ancb["original"].id
SOURCE_BUCKET = aws_s3_bucket.ancb["source"].id
TO_PROCESS_BUCKET = aws_s3_bucket.ancb["to-process"].id
WORKING_BUCKET = aws_s3_bucket.ancb["working"].id
}
}
tags = {
Environment = var.env
Terraform = true
}
}
Here is the error received:
Error: At least one field is expected inside environment
on .terraform/modules/ancb/services/ancb/main.tf line 29, in resource "aws_lambda_function" "ancb_chunker":
29: resource "aws_lambda_function" "ancb_chunker" {
I expect the code to work for both but in my testing the environment variables that I set for "chunker" don't work. If I put the environment variables for "controller" in the "chunker" variables, I'm able to create the function with no issue...