Hi,
I am not sure If I found a bug or that what I am doing here is wrong.
I am not that experienced yet using terraform.
We have setup a lambda resource like
resource "aws_lambda_layer_version" "lambda_requests_layer" {
count = var.some_var == "true" ? 1 : 0
# Zip file is generated somewhere else and only available when the var above is true
filename = "requests_python.zip"
layer_name = "python_requests_layer"
description = "Python layer containing requests module"
compatible_runtimes = ["python3.8"]
source_code_hash = filebase64sha256("requests_python.zip")
}
However when running the terraform plan it complaints about the missing zip file even though the some_var variable is set to false and the resource should not be created.
error is like:
source_code_hash = filebase64sha256("./requests_python.zip")
Call to function “filebase64sha256” failed: no file exists at requests_python.zip.
so it looks like the the filebase64sha256 function is triggered anyways.
Is there a way to prevent this… ?
Or is this some kind of a bug?
kind regards,
Zenz