deno-lambda
deno-lambda copied to clipboard
Working Directory is ignored in the Docker Image
I have the following configuration in Terraform:
resource "aws_lambda_function" "this" {
# ...
image_config {
working_directory = "/var/task/foo/bar"
command = ["baz.handler"]
}
}
but the bootstrap script seems to be ignoring the working_directory parameter and tries to import /var/task/baz.js instead of /var/task/foo/bar/baz.js - as a workaround I commented out the parameter and changed the command to ["foo/bar/baz.handler"]
Atm CMD ["foo/bar/baz.handler"] is the way forward. In some sense that's not a workaround but has always been the way to reference files not at the top level.
It's unclear to me how to support working directory... i need to think about it a little more... what you are supposed to do with LAMBDA_TASK_ROOT vs WORKDIR? 🤔
We should run some tests with some of the default runtimes to see how they behave, that might enlighten us as to how to support workdir for the deno runtime.
Not looked into this but my suspicion is what should be done is cd into /var/task and realpath the WORKDIR (initial directory).
# realpath -m --relative-to="/var/task/" "/var/task/foo/bar/baz.handler"
foo/bar/baz.handler
and use this as the HANDLER (if WORKDIR=LAMBDA_TASK_ROOT then above is a noop).
However, for sure there will need to be DENO_DIR tweak (since it's relative atm, but shouldn't be really).