resource "aws_lambda_function" "lambda_function" {
function_name = "${local.resource_name_prefix}-lambda"
description = "Lambda to be consumed by Genesys Cloud Architect Flow"
filename = var.lambda_zip_file
handler = "main.lambda_handler"
source_code_hash = var.lambda_source_code_hash
role = aws_iam_role.lambda_execution_role.arn
runtime = local.go_runtime
timeout = local.lambda_timeout
}
But I got this error : {
"errorMessage": "Unable to import module 'main': No module named 'main'",
"errorType": "Runtime.ImportModuleError",
"stackTrace": []
}
With the python Lambda I believe the handler attribute should be "lambda_handler" and not "main.lambda_handler". "main" is the package name for the Golang Lambda.
Are you looking at deploying a WebChat solution? WebChat is our original chat product and while we still support it, no further R & D work is being performed on it. The go-forward solution is to use Web Messaging. We have a web messaging blueprint with the same flows and code, but just using WebMessaging as a solution.
Thanks,
John Carnell
Director, Developer Engagement
thanks for responding;
for the first one, changing the "main.lambda_handler" to "lambda_handler" returns me this error:
{
"errorMessage": "Bad handler 'main': not enough values to unpack (expected 2, got 1)",
"errorType": "Runtime.MalformedHandlerName",
"requestId": ".................",
"stackTrace": []
}
thanks for responding;
my problem is not about creating or dealing with lambda function, I'm familiar with it.
the problem I'm facing is the one I have explained in the post.
Thanks
My apologies, I assumed that error was from AWS when failing to run your lambda function. Can you provide some context about which part of your code is throwing that error?
Sure; the prblem mainly in the lambda.tf file; It can not read the lambda function and always return me this error :
{
"errorMessage": "Bad handler 'main': not enough values to unpack (expected 2, got 1)",
"errorType": "Runtime.MalformedHandlerName",
"requestId": ".................",
"stackTrace": []
}
the file that contains the lambda function is main.tf so I tried to replace script to this :
resource "aws_lambda_function" "lambda_function" {
function_name = "${local.resource_name_prefix}-lambda"
description = "Lambda to be consumed by Genesys Cloud Architect Flow"
filename = var.lambda_zip_file
handler = "main.lambda_handler"
source_code_hash = var.lambda_source_code_hash
role = aws_iam_role.lambda_execution_role.arn
runtime = local.go_runtime
timeout = local.lambda_timeout
}
then I got this error : {
"errorMessage": "Unable to import module 'main': No module named 'main'",
"errorType": "Runtime.ImportModuleError",
"stackTrace": []
}
I suggest you take a look at the terraform AWS provider docs. This a problem that really centers more around how the AWS terraform provider is deploying the Lambda. We are using the Terraform AWS provider "out of box", but we wrote our Lambdas in Golang so not sure what the issue might be.