Hello! I'm having problems using the layers with E...
# help
i
Hello! I'm having problems using the layers with ESM lambda and I have confirmed that this is an ongoing issue through this twitter post: https://twitter.com/coderbyheart/status/1486470882008645634?s=20&t=Vtq1BPfn1wfM2hc0mpKnDw Now they have a workaround(https://github.com/vibe/aws-esm-modules-layer-support) for this issue and I'm trying to follow the workaround. I was able to create a symlink using the commandHooks. However, I don't know how to add the symlink option during the creation of the zip files.
f
Hey @Ian, thanks for sharing!
Can u do smth like this?
Copy code
import { execSync} from "child_process";

// creates function.zip
execSync("zip --symlinks -r function.zip .");

// create a layer with function.zip
const layer = new lambda.LayerVersion(this, 'Layer', {
  code: lambda.Code.fromAsset('path/to/function.zip')),
});
i
Hello @Frank, thanks for the reply. The lambda function is the one that should be zipped with the symlink flag. For reference, in the image below here's what I got when I run "npm run build". The node_modules is the symlink file. Now when I run "npm run deploy", is there an option to add the --symlinks during the zipping of these artifacts? I tried this manually by zipping the artifacts with the symlink flag, then uploading it in my lambda function and the workaround actually works.
Gentle bump @Frank @Jay
j
@Ian I haven't looked at this before but any idea how you would do this in CDK?
i
Thank you for the response @Jay I'm new to serverless, so I don't know much about SST and CDK. I'll try to figure it out and let you know if there are any updates. Thanks!