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 )

Комментарии • 46

  • @foobar_codes
    @foobar_codes  5 лет назад

    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!

    • @chen-li
      @chen-li 5 лет назад +1

      Thanks for the informative video! BTW, the link above seems to be pointing to this same video

    • @rsdraul
      @rsdraul 4 года назад

      @@chen-li Yup, these seems to be the one for those looking:
      ruclips.net/video/FyB0dsUwRSI/видео.html

    • @ayami123
      @ayami123 2 года назад

      is the new one the same ?

  • @vtp-uk
    @vtp-uk 5 лет назад +9

    Can you make another video about how to create separate Lambda Layers (a serverless project) and integrate them to different Lambdas (other serverless projects)?

  • @binary-brackets
    @binary-brackets 4 года назад +1

    Thank you foobar, Nice explanation! it helps me lot!

  • @codenjourney6656
    @codenjourney6656 4 года назад +1

    Thanks for the excellent lecture

  • @yankee-in-london
    @yankee-in-london 5 лет назад +2

    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.

    • @foobar_codes
      @foobar_codes  5 лет назад +1

      you can put the ARN of the layer in the serverless.yml and use two different serverless framework projects.

  • @nikhilvaka8899
    @nikhilvaka8899 3 года назад +1

    Thank You ..Nice explanation. It helps me lot.. How we can customize lambda layer within account in serverless yml file using Pseudo parameters.

  • @codingexpedition4625
    @codingexpedition4625 5 лет назад +1

    Nice video. Certainly something to explore. Did aws put the re:invent talk about layers online?

    • @foobar_codes
      @foobar_codes  5 лет назад

      Yes SRV375 - [NEW LAUNCH!] Lambda Layers
      But its a chalk talk so it wont be in youtube :(

  • @jlu
    @jlu 2 года назад +1

    Doing
    package:
    patterns:
    - '!layers/**'
    - '!node_modules/**'
    Always returns 'No file matches include / exclude patterns' for me, any idea why?

  • @juliansanchez5461
    @juliansanchez5461 5 лет назад +1

    Geniales tus videos !! saludos desde Colombia

  • @shacco6563
    @shacco6563 5 лет назад +1

    thank you

  • @cortesbr8131
    @cortesbr8131 Год назад

    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...

  • @tomding2789
    @tomding2789 2 месяца назад

    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

  • @kristofferhaukaasberg6258
    @kristofferhaukaasberg6258 5 лет назад

    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?).

    • @foobar_codes
      @foobar_codes  5 лет назад

      I have not tried that but there is an layer for it, so i imagine it can work github.com/mthenw/awesome-layers

  • @TheMainCOW
    @TheMainCOW 5 лет назад

    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?

  • @DiegoRFGonz88
    @DiegoRFGonz88 5 лет назад

    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)

  • @benderino42
    @benderino42 3 года назад

    Hey. The link for serverless course does not work. Could you send me a new one?

  • @orrlevinger
    @orrlevinger 3 года назад

    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?

  • @fede_balderas
    @fede_balderas 5 лет назад +1

    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?

    • @EDUSidekick
      @EDUSidekick 5 лет назад +2

      Yep! Layer can be managed as a completely separate project/folder and can have its own deployment life-cycle.

    • @fede_balderas
      @fede_balderas 5 лет назад +1

      Nice!!! thanks @@EDUSidekick

  • @angelcostales7022
    @angelcostales7022 4 года назад +1

    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?

    • @angelcostales7022
      @angelcostales7022 4 года назад

      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

    • @angelcostales7022
      @angelcostales7022 4 года назад +1

      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.

    • @angelcostales7022
      @angelcostales7022 4 года назад +1

      Y ya solo me queda agradecerte por los videos! para los que no habíamos tocado todo esto nos viene genial. Mil gracias.

    • @foobar_codes
      @foobar_codes  4 года назад

      Jaja! Gracias por poner la solucion a tu problema :) Asi si alguien tiene el mismo problema puede mirar aca. Saludos

  • @contractorwolf
    @contractorwolf 5 лет назад +1

    if you are putting your layers in another project, how do you reference them from the project that contains your functions?

    • @fede_balderas
      @fede_balderas 5 лет назад +5

      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

    • @contractorwolf
      @contractorwolf 5 лет назад +1

      @@fede_balderas nice! thanks for the quick reply (and great content)

  • @nihas5264
    @nihas5264 3 года назад

    Doubt, can we use layers in a custom authoriser?

  • @user-rc1jv7dy5i
    @user-rc1jv7dy5i 10 месяцев назад

    Someone has this error when try execute sls package ?
    ERROR: Cannot read file node_moduñes/.. - EMFILE: too many open files

  • @youtubedemointegrator6836
    @youtubedemointegrator6836 5 лет назад

    any idea how we can access FFmpeg in lambda function for extract image from s3 video

  • @thecloudfunction894
    @thecloudfunction894 5 лет назад

    have u been able to access to files into layers? when I try to require('/opt/layerPath/file') it cannot find the route

  • @kiranmarati1201
    @kiranmarati1201 5 лет назад

    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.?

  • @DanielPereiraBP
    @DanielPereiraBP 5 лет назад

    Is it possible to use "local invoke" working with layers?

  • @KevinToala96
    @KevinToala96 5 лет назад

    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

    • @KevinToala96
      @KevinToala96 5 лет назад +2

      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.

  • @AbhijitSrivastava
    @AbhijitSrivastava 5 лет назад

    I appreciate the effort but there are few mistakes. Example, you can wrap layers in nodejs folder, and avoid changing the node path.

    • @shacco6563
      @shacco6563 5 лет назад

      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

  • @alexnguyen411
    @alexnguyen411 2 года назад

    Please code sample link in video 😍😍😍😍