Setup AWS Serverless Project with Typescript Lambda Functions

Поделиться
HTML-код
  • Опубликовано: 4 июл 2024
  • I will guide you guys on setting up a serverless project with typescript lambda functions for AWS. I will help in setting up some example HTTP triggered lambdas, as well as an SNS topic trigger lambda. I will also show how to configure serverless to deploy to AWS as well as run in offline mode and how to debug your lambdas locally.
    Starter Project link: github.com/leoroese/aws-ts-se...
    Finished: github.com/leoroese/aws-ts-se...
    Useful Documentation
    Serverless: www.serverless.com/framework/...
    DefinatelyTyped: github.com/DefinitelyTyped/De...
    Timestamps
    0:00 intro
    0:30 what is serverless
    4:40 project start setup
    7:30 serverless config
    10:30 http triggered lambdas
    14:28 serverless deploy
    16:55 sns resource
    18:40 sns triggered lambda
    19:56 serverless offline
    25:20 setup debugging

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

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

    Assumption was that AWS may have been configured on your machine already. But if not you can quickly follow along here: documentationnerds.com/blog/tech/configure-aws-cli

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

      Site is offline for me atm.

  • @mosespeter9711
    @mosespeter9711 Год назад +3

    This is undoubtably the best serverless video on internet

  • @tarunhasija4751
    @tarunhasija4751 8 месяцев назад

    After investing over 48 hours into learning about serverless from various sources and blogs, I was surprised to find that this video managed to encapsulate the entire topic in just under 30 minutes. Outstanding job, Leo!

  • @seeds_of_growth-yi5gx
    @seeds_of_growth-yi5gx Год назад

    Thanks a lot, for being on-point and touching upon important parts of the topic.
    On the debug section, in the run configs, the "protocol" is not longer supported, and for me it was just exiting with 1
    so I added the --verbose flag to know what's going on, and just adding --verbose as follows, solved the problem and the debugger works great!
    "args": ["offline", "start", "--httpPort", "4000", "--noTimeout", "--verbose"],
    Cheers!

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

    bro you are my hero, this tutorial really helped me to deploy my existing project!

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

      Glad I could help!

  • @Lodka_Is_Sad
    @Lodka_Is_Sad 3 месяца назад

    Thank you very much man, you teaching so clearly, that's cool for sure

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

    Just got a new subscriber, great content. This is awesome!

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

    Hi, Very useful video. Thank you a lot! 😄

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

    This is dope man thank you

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

    Great video, thank you so much

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

    Awesome vid. Subbed!

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

    Nice intro and tutorial

  • @khandoor7228
    @khandoor7228 2 года назад +2

    Great tutorial Leo, I use a lot of AWS + Serverless would love to see more, especially queryStringParameters with Lambdas and Dynamo tables. If you could do a video on pathParameters for pagination and searching by queryStringParameters I think would be awesome. just an idea.

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

      Thanks, KhanDoor! Yeah, I personally love using Serverless, I hope to eventually get to learn about those things you mentioned and if I do I will be sure to make a video on it!

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

    Amazing video bro.
    I am struggling to debug typescript aws cdk lambda.
    It will be very great if you post video for that as well.

  • @ChrisTian-ox5nr
    @ChrisTian-ox5nr 2 года назад

    Legend!

  • @alanrodriguezw.9149
    @alanrodriguezw.9149 2 года назад

    Thanks You!!

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

    Dude Amazing! Great video. Super helpful!
    Question: feelings on terraform?

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

      Thanks Christopher, my feelings is that I wish I had more time to be able to get my hands dirty with it haha. I've heard good things about it though!

  • @betheleyo2701
    @betheleyo2701 Месяц назад

    Good work, but you missed explaining all the permissions in an aws iam policy file that is needed to be able to run a successful "serverless deploy" command, it took me a while to have that set up

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

    as Luke as all ready requested, could you please do a quick addition or just foot note to this video where you talk about how to have each Lambda be self contain and deployable on it's own as well as having a parent template that imports all others, giving the option to either deploy all Lambdas at once or just a single Lambda. It is something that I see a lot of projects that grow in size require, but often hit a road block on as they are all written with the intent to deploy all Lambdas at once.

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

      Oh I haven't quite come across that recently. I will try and get around to it if I can!

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

    Hi- Is there a way you can add a lambda layer demo as well?

  • @76Freeman
    @76Freeman 2 года назад

    Hi Leo,
    Great video, I've just stepped in the land of Serverless :) and your video was of great help. I'm wondering if you've ever used it in conjunction with Hasura?
    Thank you again

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

      I have not had the chance to use Hasura but I have heard good things about it.

    • @76Freeman
      @76Freeman 2 года назад

      ​@@CodeDunks I'm actually working with it right now and I need to create a user when a user confirms his signup. Do you know I could test a lambda that is triggered when the user confirms the signup.
      Right now I'm getting an error "Unrecognizable lambda output"
      This is my lambda:
      import { GraphQLClient } from 'graphql-request';
      import { Callback, Context } from 'aws-lambda';
      const adminSecret = process.env.ADMIN_SECRET;
      const hgeEndpoint = process.env.HGE_ENDPOINT;
      export const handler = async (event: any, context: Context, callback: Callback): Promise => {
      try {
      const headers = {
      headers: {
      'x-hasura-admin-secret': adminSecret as string,
      },
      };
      const graphqlClient = new GraphQLClient(hgeEndpoint as string, headers);
      const qv = {
      email: event.request.userAttributes.email,
      };
      await graphqlClient.request(
      `mutation InsertUser($user: users_insert_input!) {
      insert_users_one(object: $user) {
      id
      }
      }`,
      qv
      );
      callback(null, event);
      } catch (e) {
      console.warn('error', e);
      callback(null, false);
      }
      };

  • @mugdhawadhokar1071
    @mugdhawadhokar1071 Месяц назад

    hey great video. Here I am confuse about invcocation API, why does it generates and can we avoid it from generating ?

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

    Is it okay to use the lambda without using the APi Gateway too? And does lambda support Class based node js app?

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

    How can I setup the command 'template-cli' like you do? Would you mind share some tutorial about it?

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

      Hey there you can look at either my video or article I made about it.
      Video: ruclips.net/video/xYko2bHNgVA/видео.html
      Article: documentationnerds.com/blog/tech/template-cli-with-node-and-inquirer

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

    @leo Roese can you Please guide me? I am confused in two type serverless project build one HTTP API nodejs and express API node. what's different in that and when we create http api nodejs project and when we create express api nodejs project?

  • @seeds_of_growth-yi5gx
    @seeds_of_growth-yi5gx Год назад

    Why in the hello arg is _event, and goodbye is just event without underscore ?

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

    I'm experiencing a peculiar error, and I'm hoping that you might have seen the same one. When I run local testing, everything works fine with imported modules. But when I deploy it to lambdas, any handler that use a library from a separate file will crash with "cannot find module as if dependencies aren't being installed. However any dependencies directly in a handler file works just fine.

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

      Hey Glen, when you say a library from a separate file what do you mean? For example, if you have this lambda project as a sub repository and are accessing another sub repositories interface then this is expected. The reason for that is that serverless will only package up the lambda projects files. So locally it works because it can access the "other library" on your local machine, but that "other library" does not exist within the package on AWS. This link might be of some use also
      aws.amazon.com/premiumsupport/knowledge-center/lambda-deployment-package-nodejs/

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

      ​@@CodeDunks Hello Leo, from further investigation I can see that it is just any node module that cannot be found. Which perplexes me greatly, as I've followed the same structure as you have. From the link you send, do I understand correctly that this article wants me to change my code structure to have functions in root with package.json?

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

      @@glenjensen3683 Hmm that is odd. Couple of things you can try.
      1) run yarn install again to make sure dependencies are installed correctly
      2) run "yarn sls package -s dev" then check in your .serverless folder in the root of your current directory for your projects generated zip, then within that zip see that node_modules is in there with whatever dependency it says that it's missing.
      3) If all else fails, try possibly copying the project from my repo in the description and see if that works.

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

    Show us how to do a multi-module (like, a serverless.yml and package.json for each module, where what goes in common vs each module, that kinda thing). Pleez, pretty pleez?
    Also, any thoughts for chosing between mocha and jest? I was going to go with mocha, as it seems to have larger market share (maybe?), but I'm seeing that coverage, expect, etc for mocha has additional dependencies, like chai and istanbul to install, and configuration doesn't look as easy and breezy as with jest.

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

      I've worked with both mocha and jest and found that the overall experience with Jest is a lot better in my own personal opinion. Every industry position I've worked on has also used Jest

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

    i get a "message": "Bad request", code: 400.
    i cant find the solution

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

    What a great terminal, do you have the config files for it?

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

      Hey Rekefa, I actually just got a new computer and therefore don't have the configs yet. But here is the article I used to kinda set it up. Its a combination of windows terminal and cmder.
      medium.com/talpor/windows-terminal-cmder-%EF%B8%8F-573e6890d143

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

      @@CodeDunks Thank you very much!

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

    Using AWS lambda I'll have a lot of external IPs? I need an cheap solution to run my API with a lot of external IPs.

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

      I am not entirely sure what is being asked here. Could you elaborate?

  • @limpep
    @limpep 3 месяца назад

    s3 triggers, schedulers

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

    Have been working with serverless some yrs now. Do not mix serverless concept and microservices. There are some microservices written in nodejs in a ec2 container that are not serverless and there are some serverless system that are not microservices at all. And there are some real serverless microservices and on top of this concepts there are lambdas vs non lambdas microservices and also lambdas that are restful apis or a simple lambda with no endpoint....also that brings the idea of Functional paradigm vs oop in lambdas/serverless/microservices approach....