Lambda layers with Serverless Framework and good practices | Serverless
HTML-код
- Опубликовано: 18 сен 2024
- I will show you how to use lambda layers with Serverless Framework and some good practices on handling them.
★★ README / OPEN ME ★★
☆ SUBSCRIBE TO THIS CHANNEL: bit.ly/foobar-y...
☆ SHARE THIS VIDEO: • Lambda layers with Ser...
☆☆ ABOUT THIS VIDEO ☆☆
I will show you how to use lambda layers with Serverless Framework and some good practices on handling them.
A lot of the questions asked in the comments are answer in this other video: • AWS Lambda Layers Q&A ...
Original project: github.com/mav...
Middy video: • Using Middy in serverl...
Final code github: github.com/mav...
☆☆ FOLLOW ME ONLINE ☆☆
Twitter - mavi888uy - / mavi888uy
Instagram: foobar_codes
Facebook: / foobarcodes
Follow my blog at: bit.ly/foobar-blog
More info - marciavillalba.com
Check my Serverless course: bit.ly/serverle...
☆☆ ABOUT FOOBAR ☆☆
In this channel you can find mostly coding tutorials related to cloud and serverless.
In addition, I like also talking about architecture, software design, motivation and leadership.
There is a new video every Tuesday, so stay tuned :)
☆☆ SPONSORSHIP ☆☆
Does your company wants to sponsor a video? Contact me by twitter or by email (email address in the about page)
Thanks Gabrielle Marie for the lovely assets for my intro ❤️ (check her channel here: / glamsolutions )
I answer a lot of your questions in this video: ruclips.net/video/aKD9Vftr6i4/видео.html
Go and check it out to see if it helps you out!
Thanks for the informative video! BTW, the link above seems to be pointing to this same video
@@chen-li Yup, these seems to be the one for those looking:
ruclips.net/video/FyB0dsUwRSI/видео.html
is the new one the same ?
Can you make another video about how to create separate Lambda Layers (a serverless project) and integrate them to different Lambdas (other serverless projects)?
Thank you foobar, Nice explanation! it helps me lot!
That is great to hear 😊
Thanks for the excellent lecture
Thanks Foo Bar. Was interested in if you had any additional info the the “don’t do the layers in the same repo” comment? I use the Serverless framework and being able to have automatic linking between layer and function is quite useful. Wondering how to work around this constraint if possible.
you can put the ARN of the layer in the serverless.yml and use two different serverless framework projects.
Thank You ..Nice explanation. It helps me lot.. How we can customize lambda layer within account in serverless yml file using Pseudo parameters.
Nice video. Certainly something to explore. Did aws put the re:invent talk about layers online?
Yes SRV375 - [NEW LAUNCH!] Lambda Layers
But its a chalk talk so it wont be in youtube :(
Doing
package:
patterns:
- '!layers/**'
- '!node_modules/**'
Always returns 'No file matches include / exclude patterns' for me, any idea why?
Geniales tus videos !! saludos desde Colombia
thank you
I did the process of creating a .zip with the contents of a chartjs-node-canvas lib, and uploading it to a layer. I took the ARN of that layer and put it in my function, but I always get the error "errorMessage": "ChartJSNodeCanvas is not define. what to do? please someone help me with this question...
What if there are multiple projects using the same layer, and I want to develop under vscode, how to address with code intelligence? because the layer is up on aws, Thanks
Great explanation, thanks:) I ended up deploying functions individually instead of full deploy, and it worked great. So fast! Just a quick question: would a big library like Chrome puppeteer work in a layer like this you think? (haven't checked the size and howto, but I theory, would it work?).
I have not tried that but there is an layer for it, so i imagine it can work github.com/mthenw/awesome-layers
Hello! I am trying to run my Lambda function locally using AWS SAM and I have created TensorFlow Layer. But every time I try to run my function I get following error: error while loading shared libraries: libtensorflow.so: cannot open shared object file: No such file or directory. Any idea how can I fix this?
Is there a way to make the lambda function to point to the lastest version of the layer? without having to make the same as you in this video? (I have them layer-service in different projects)
Hey. The link for serverless course does not work. Could you send me a new one?
can i make just a node_modules layer that points to the node_modules directory as default layer and point all my lambdas to it until i create a more granular layer? and than all my lambdas will be small?
If we have another Serverless service just with the layers, is it possible to deploy just one layer (when it changes) or we have to deploy the all service everytime?
Yep! Layer can be managed as a completely separate project/folder and can have its own deployment life-cycle.
Nice!!! thanks @@EDUSidekick
Hola Marcia!! estoy intentado combinar dos de tus videos en una sola prueba: el de multiples entornos video #4 (env-parameter-test) + lambda layers (este video sobre el que comento)... Por ponerte en contexto; tengo dos proyectos serverless, uno para el layer y otro para la lambda (como recomendaste de buena practica), la consulta es que no consigo que la lambda encuentre el modulo de middy. En el proyecto de la la función de hello le estoy referenciando el layer arn.. se despliega todo bien (y veo desde la consola de AWS que la lambda tiene la layer del otro proyecto). pero cuando pruebo la lambda me dice: estoy pensando que puede ser por el NODE_PATH que no lo he puesto en el proyecto de la función porque la variable provider.. "environment" ya tiene un valor (creo que para poder usar las variables desde el código) por eso no puedo usarla para mapearla con el NODE_PATH. ¿podrías ayudarme?
he quitado el valor de "environment" y he colocado "NODE_PATH: "./:/opt/node_modules"" y he probado de nuevo. Lo bueno es que ya no me sale el error de middy (lo que significa que si era esto).. pero ahora como la variable "environment" no se define bien.. lo que sucede es un nuevo error que dice: authorized bla bla.... to parameter/env-parameter-test/undefined/value1.... si te fijas en la ruta aparece "undefined" con lo cual significa que no se está generando bien la variable del "environment".. :( no se como puedo resolver esto, si se te ocurre algo ¿puedes ayudarme? Muchas gracias de antemano :D
Encontré la solución, simplemente coloque "environment" con el NODE_PATH dentro del contexto de la función y deje la otra variable "environment" tal cual dentro de provider. Entiendo que colocarla en el contexto de "provider" la hace común para el resto de funciones, por lo que si es necesario usar dicha layer en multiples funciones habrá que configurarle el environment con el NODE_PATH a cad una.
Y ya solo me queda agradecerte por los videos! para los que no habíamos tocado todo esto nos viene genial. Mil gracias.
Jaja! Gracias por poner la solucion a tu problema :) Asi si alguien tiene el mismo problema puede mirar aca. Saludos
if you are putting your layers in another project, how do you reference them from the project that contains your functions?
With the ARN of the layer: serverless.com/framework/docs/providers/aws/guide/layers#using-your-layers
functions:
hello:
handler: handler.hello
layers:
- arn:aws:lambda:region:XXXXXX:layer:LayerName:Y
@@fede_balderas nice! thanks for the quick reply (and great content)
Doubt, can we use layers in a custom authoriser?
Someone has this error when try execute sls package ?
ERROR: Cannot read file node_moduñes/.. - EMFILE: too many open files
any idea how we can access FFmpeg in lambda function for extract image from s3 video
have u been able to access to files into layers? when I try to require('/opt/layerPath/file') it cannot find the route
When we update layer package, will my lambda function automatically picks latest version of layer or do we also need to update the latest version of layer in lambda function.?
Is it possible to use "local invoke" working with layers?
Muy buen video. Gracias.
Si quisiera hacer este mismo proceso pero con un proyecto Javen y Maven, como se deberia de hacer esto ?. No encuentro ejemplos de esto
Lo tengo.
Las dependencias en maven deben de ser marcadas con el scope "provided" y generar una copia de todas las depedencias con mvn copy-dependencies, para asi generar un zip que se podra utilizar como lambda layer.
I appreciate the effort but there are few mistakes. Example, you can wrap layers in nodejs folder, and avoid changing the node path.
it is not a mistake. yes you can do that but any time you deploy you create a new version. you wont be able to separate devdependencies from dependencies and you will have a huge layer probably so huge that will pass the limits. so listen to her and do separated projects ymls for your layers
Please code sample link in video 😍😍😍😍