Creating an API with Serverless - API Gateway and AWS Lambda

Поделиться
HTML-код
  • Опубликовано: 3 дек 2024

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

  • @johnbarker5686
    @johnbarker5686 3 года назад +10

    Great tutorial- thank you so much!
    Updating this to latest:
    provider:
    ...
    httpApi:
    cors: true
    functions:
    getUser:
    handler: lambdas/getUser.handler
    events:
    - httpApi:
    method: GET
    path: /get-user/{ID}

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

      You saved me from going off the rails, thank you! This should probably be stickied at the top.

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

      Yes, there's a v2 of serverless now which has made the inclusion of httpApi. You should still be able to use "http" though

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

      @@rayandwayne3275 Glad that you found it useful

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

    the bestttt video series ever for js developers!! thank you!

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

    Great simple and clear.. that is what I was looking for, tutorials that go straight to the point .. thank you

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

    Great training videos series! I'm currently studying for developer associate and this is helping cement the concepts.

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

    These are amazing tutorials. You should consider opening a course on Udemy. You are way better than those AWS Udemy instructors.

    • @CompleteCoding
      @CompleteCoding  3 года назад +2

      I've done one small course on Udemy but I'm considering doing a RUclips SaaS build series and then adding extra details and putting it on Udemy too.

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

    Thanks Sam for the great video.

  • @ญาติมาชูเรือง

    Great tutorial - thank you so much

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

    Hi Sam,
    I noticed I had to comment all the lines inside DemoBucketUpload when I tried to run "sls deploy" command because of this error :
    An error occurred: NewResource - mynewbucketwithserveless-1927 already exists.
    After that, it works!
    ( You can see this section in this video at 10:36 )

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

      That just means that someone has already claimed that bucket name. It might even have been you in a previous project.
      You could have also just altered the bucket name to achieve the same result

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

    Wow man! Thats really helpful, I really appreciate your effort what you're putting...Thanks a lot!

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

    Thank you thank you thank you very much sir for this video

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

      Thanks for commenting on all my videos :) It really helps share them to more people

  • @РомаСамуйлов-ъ6у
    @РомаСамуйлов-ъ6у Год назад +1

    Thank you for the video. It didn't show me a link to check this function. Where can I find my link?

  • @MK-Turtles
    @MK-Turtles 4 года назад

    Thank you very much for this amazing video!

  • @eespxtra1059
    @eespxtra1059 4 года назад +2

    Thank you so much for this guide. I did everything the way you teach but I have a problem because when I go into endpoint I have an error {"message": "Internal server error"} - How to fix this ??

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

      This means there's a bug in the code. You can run
      sls logs -f ${yourFunctionName}
      to get the latest logs. You should then be able to see what the error is from them. The other option is to go into the console, find your lambda, select "monitoring" and then "View logs in CloudWatch" which will show you the logs in the console.

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

    Awesome video!
    I was wonder, do you prefer working with js or typescript?

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

      I definitely prefer typescript now. It took a bit to get used to but makes everything more consistent now.
      I can define what I expect to receive from an api request and then everything will autocomplete. It warns me when I pass an incorrect parameter or have a typo.

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

    Hi, Excellent tutorial. I need help to identify the problem why I'm getting a 502 in the browser when I try to run the API. serverless deploy worked fine. Thank you.

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

    Thx for good video again!

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

    Great video

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

    Starting to watch

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

    This is fantastic. But is the a specific reason why you chose to use Require.JS rather than ES6 modules? Anyway, thanks and keep 'em coming.

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

      The first few videos in this series were done before the use of webpack. If you try and use ES6 and import without webpack then your lambdas will always error. I probably should have updated them all in the webpack video.

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

    Great video, do you know an example of applying idempotency to the api to avoid repeated requests?

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

      You could write a 'lock' to a dynamo table on the first request so later requests know not to process.
      Idempotency is usually only be required for update requests where the data is relative to the current value. Eg. Increment likes by one.
      I try to avoid this kind of request where ever possible, instead providing the actual values.
      I avoid it because there are almost always race conditions or other effects that can cause issues.

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

      @@CompleteCoding ok thanks a lot for explaining

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

    All... Excelent!!

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

    hello, this is a great tutorial by the way!!! I have two quick questions which I wish you could demonstrate in the video as well, was
    1. How do you invoke the message, {message: "missing the ID from the path"} and
    2. how do you access 'event' which you console logged from the editor?
    Thanks!!!

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

      You can't trigger that message via the api. If you don't pass an id then api gateway won't pass the message to the lambda. Its likely to happen if you point the wrong endpoint to the wrong lambda.
      To see the logs, open the lambda in the console. Then click the 'monitoring' tab and 'view in cloudwatch'. You can see everything that gets console.log out in your code.

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

      @@CompleteCoding Thank you!!! Best tutorial

  • @HariHaran-nf9ky
    @HariHaran-nf9ky 3 года назад

    Sir I did upto deployment....after i'm open the url and it show "Missing Authentication Token"

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

      That means that either you're probably on the wrong url.

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

    great video!

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

    Keep it up!

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

    I believe the response object in API Gateway has changed;
    status -> statusCode
    now we have a property isBase64Encoded that we can set to false

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

      Yes, it should be statusCode now :) Nice spot

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

    Hello sir how to perform in vscode all those cli commands

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

      You can open the terminal in VS Code using "View > Terminal" or there are shortcuts. This then works as any other terminal would do.

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

    Whenever I deploy and open the url I get an internal server error how do we fix it ?

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

      First look at the cloudwatch logs. Does that indicate why the lambda is erroring.
      You can then wrap your code in a try-catch block and log out the error.
      Once you know the error that is causing it, you can fix it.

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

    Excellent video !
    Could you make video on how building a deployment package using serverless and python?

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

      I've not done much with Python in production but the process is the same.
      create a new project with "sls create --template aws-python --path myService"
      setup your AWS credentials if you haven't already
      modify the python endpoint or create more of your own
      update the serverless.yml file for your changes or new endpoints
      sls deploy

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

      @@CompleteCoding Thanks ! I'm sorry I was not clear enough. Sometimes, with python I have very large dependencies (with c bindings), given that the max size is about 250MB, i was wondering if there was a way to circumvent this with serverless.

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

      You can use Lambda Layers or EFS to get around this. Lambda layers would be easier but still has file limits. EFS would allow much larger dependencies.
      I've got a video on Layers (not with serverless though) ruclips.net/video/5a2LS7gNECk/видео.html
      I've not done a video on adding EFS to lambda yet

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

      @@CompleteCoding thank you mate

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

    Getting to enter path(0), path(1) after entering sls deploy... Wt to do?

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

      I've not seen that error before. Have you entered the path for the endpoints in the serverless.yml file?

    • @753abhishek
      @753abhishek 4 года назад +1

      use

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

      I think this is due to a conflict with a PowerShell select command. If you use the following it should temporarily remove the alias for the session:
      Remove-Item alias:sls
      After this sls deploy should work as you would expect.

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

    Heloo
    Wt was extension needed for serverless. Yml file?

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

      You don't need any vs code extensions to use serverless.yml files

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

    Is your demo source code on Github?

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

      Just added it to the description but here they are for you.
      starting code: github.com/SamWSoftware/ServerlessRUclipsSeries/tree/lesson2-S3
      final code: github.com/SamWSoftware/ServerlessRUclipsSeries/tree/lesson3-api