Reputation: 61
Having some issue when applying my terraform plan, and cannot pinpoint what is the problem in it. I tried everything I could think about. Here is my lambda.tf file:
data "archive_file" "projectLeo_listunsubscribe_lambda_code" {
type = "zip"
source_dir = "${path.module}/../src/ProjectLeo.ListUnsubscribe"
output_path = "${path.module}/../src/code-packaged/list-unsubscribe.zip"
}
resource "aws_lambda_function" "projectLeot_list_unsubscribe_lambda" {
filename = "${data.archive_file.projectLeo_listunsubscribe_lambda_code.output_path}"
function_name = "projectLeo-listunsubscribe-lambda"
role = "${aws_iam_role.projectLeo_list_hygiene_role.arn}"
handler = "${var.lambda_list_unsubscribe_function_handler}"
runtime = "dotnetcore2.1"
memory_size = "256"
timeout = 120
publish = true
reserved_concurrent_executions = 1
environment {
variables = {
optout-topic-arn = "${data.aws_sns_topic.projectLeo_optout_topic.arn}"
}
}
}
data "aws_sns_topic" "projectLeo_optout_topic" {
name = "${var.sns_optout_topic_name}"
}
The plan generated looks all fine, ut this error is generated when apply is done:
Error: Error creating Lambda function: ValidationException:
status code: 400, request id: c16dc369-bccd-418d-a2b5-2d0383c66064
on ..\list-unsubscribe\infrastructure\lambda.tf line 9, in resource "aws_lambda_function" "projectLeo_list_unsubscribe_lambda":
9: resource "aws_lambda_function" "projectLeo_list_unsubscribe_lambda" {
That's quite a light log to work with, I tried updating pieces by pieces of the code but always have the same result.
Can anybody help me pinpoint what may be the issue with my code? Thanks!
Upvotes: 1
Views: 4183
Reputation: 61
Finally manage to identify the issue: the environment variables in AWS lambda function doesn't accept hyphen (-). I replaced it by underscore and it went through.
optout-topic-arn became optout_topic_arn
Upvotes: 5