node-geo-tz
node-geo-tz copied to clipboard
ENOENT: no such file or directory, open '/var/data/geo.dat' when running on AWS lambda
Getting the above error when trying to use node-geo-tz in an AWS lambda function.
I've upgraded to the latest version of the library, but the issue still occurs.
Is it possible to get this library to work without having to access the file system?
I try to put the library into Lambda Layer, and it is working for me.
This issue is probably related if not duplicate to https://github.com/evansiroky/node-geo-tz/issues/111.
Running into a similar issue.
@monemo12 What does your layer look like for getting this to work in a lambda?
Tried doing something like this in cdk
const geoTzLayer = new fn.LayerVersion(this, 'GeoTzLayer', {
code: fn.Code.fromAsset('node_modules/geo-tz'),
compatibleRuntimes: [fn.Runtime.NODEJS_18_X],
description: 'Lambda Layer for geo-tz library',
});
const lambda = new fn.Function(this, 'Function', {
........
layers: [geoTzLayer],
Hi @gciluffo, this is my layer and lambda looks like:
const lambdaLayerConfig: Pick<
aws_lambda_nodejs.NodejsFunctionProps,
"layers"
> = {
layers: [
new aws_lambda.LayerVersion(this, "SharedPackage", {
code: aws_lambda.Code.fromAsset(
path.join(FUNC_PATH, "genericLayer/layer.zip")
),
compatibleRuntimes: [
aws_lambda.Runtime.NODEJS_14_X,
aws_lambda.Runtime.NODEJS_16_X,
aws_lambda.Runtime.NODEJS_18_X,
],
}),
],
};
const lambda = new fn.Function(this, 'Function', {
........
memorySize: 325,
bundling: {
externalModules: ["geo-tz"],
},
...lambdaLayerConfig,
ps. I also adjusted memorySize
to aviod memory problem when layer starts at runtime.
Hi 👋🏽
we faced the same issue and thought to solve it with a layer as well. But once we want to deploy to production we get the error that we can't import some dependencies like geobuf
.
Which packages exactly did you bundle in this layer? How did you create the actual dependencies in the layer? This would help a lot. If we try to bundle all of them we'd have a size of 350 MB which we cannot deploy because the limit is 250 MB.
Thank you so much 🙏🏽
@monemo12 Thanks for the response. I ended up using an api to get timezone info. We already have a mapbox api integration so just used that.