New to aws and have an question involving how layers are applied to lambdas using terraform. I have a lambda that has utilizes a layer that is a custom bash runtime for the lambda. This layer generates and downloads some certs necessary for the lambda to run and stores them as a certs.crt
file within a /opt
folder inside the lambda. If I create another layer that pulls a different set of certs and saves them within same /opt
folder with the same name (certs.crt
), would the file from the previous layer be overridden? My terraform file looks something like this
module "test_lambda" {
source = "../../modules/lambda/basic"
filename = "${module.test_lambda_artifact.artifact}"
function_name = "test-lambda"
handler = "function.handler"
runtime = "provided"
description = "test lambda"
environment="${var.aws_env}"
layers = ["${data.aws_lambda_layer_version.layer1.arn}", "${data.aws_lambda_layer_version.layer2.arn}"]
memory_size = 2048
timeout = 60
}
Any help would be appreciated and I apologize for any lack of clarity/termanology as I am new to aws and terraform.
CodePudding user response:
Lambda merges folders with the same name, so if the same file appears in multiple layers, the function uses the version in the last extracted layer.
From the Lambda developer guide