Hi there,
I am trying to create a lambda_function which builds using a python script kept in s3 (specific code below). When executing the terraform code my pipeline keeps returning the error:
Call to function “filebase64sha256” failed: no file exists at
24 test.py.zip.
The bucket policy and file all seem to be fine but for some reason this error keeps returning. I have tested creating the exact same Lambda using the same code with “filename” and storing it locally within the repo, instead of creating it from s3 and it works as expected.
Does anyone have any idea what could be causing this error? Have I got some format error in the “source_code_hash” parameter?
Any advice is welcomed. Thanks a lot.
resource "aws_lambda_function" "test_function" {
function_name = "test-lambda"
s3_bucket = var.s3_bucket["scripts_bucket"]
s3_key = "test.py.zip"
description = "test lambda 1"
role = var.role_arn
runtime = var.runtime["py37"]
layers = [aws_lambda_layer_version.txa_lambda_layer.arn]
publish = var.publish
handler = var.handler["test"]
memory_size = var.memory_size["small"]
reserved_concurrent_executions = var.concurrency["small"]
timeout = var.lambda_timeout["medium"]
source_code_hash = filebase64sha256("test.py.zip")
tags = {
Name = "test-lambda"
Project = var.project
Environment = var.environment
Department = var.department
Team = var.team
}
}