AWS API Gateway to Lambda Tutorial in Python | Build a REST API

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 พ.ย. 2024

ความคิดเห็น • 339

  • @BeABetterDev
    @BeABetterDev  2 ปีที่แล้ว +2

    Looking to become an expert on AWS Lambda? Check out my new course: AWS Lambda - A Practical Guide
    www.udemy.com/course/aws-lambda-a-practical-guide/?referralCode=F6D1A50467E579C65372

    • @Venkat28s
      @Venkat28s 2 ปีที่แล้ว

      Sorry this Course is not available in udemy. :)

  • @AlvinC-sz3li
    @AlvinC-sz3li 4 ปีที่แล้ว +97

    As an AWS engineer I have to say, very good tutorial video. Why such a channel only has 21k sub??? For begineers, your videos are better than our official ones.

    • @santhoshinfo
      @santhoshinfo 3 ปีที่แล้ว

      Thanks for your support . The subscribe count jump to 53k+ ...👍

    • @jasper5016
      @jasper5016 2 ปีที่แล้ว

      Now its 117K. Super fast.

    • @G0raXh
      @G0raXh ปีที่แล้ว

      now its 149k

    • @zackpacked
      @zackpacked ปีที่แล้ว

      254k 😮

    • @ymahtab
      @ymahtab ปีที่แล้ว

      @@zackpacked subs, not views

  • @geodezix
    @geodezix 5 ปีที่แล้ว +2

    get this ...{"transactionId": "5", "transactionType": "'PURCHASE'", "transactionAmount": "500", "message": "xyz says HELLO"} .... finally understand what api gateway/lambda is doing....great job AWS Simplified!

    • @BeABetterDev
      @BeABetterDev  5 ปีที่แล้ว

      Great to hear I was able to help!

  • @BilalAhmed-nt9gi
    @BilalAhmed-nt9gi 4 ปีที่แล้ว +8

    This dude is way more Good then actual AWS guys. And video is super sharp to the point (Y) Loved it

    • @BeABetterDev
      @BeABetterDev  4 ปีที่แล้ว

      Thank you so much for your kind words!

  • @faithinverity8523
    @faithinverity8523 4 ปีที่แล้ว +23

    Wow. Short, complete, accurate and useful. You are remarkably good at making instructional videos. Thank you.

    • @BeABetterDev
      @BeABetterDev  4 ปีที่แล้ว

      Thanks for the kind words Faithin!

  • @learndevtech
    @learndevtech 7 หลายเดือนก่อน

    This is the best exemplification I have ever seen so far. I could not find any other resources better than this channel.

  • @kono163
    @kono163 5 ปีที่แล้ว +4

    Great tutorial!
    this is just memo for other beginners.
    ●can't test in lambda console?
    try something like this ↓
    {
    "queryStringParameters":{
    "transactionId": "5",
    "type": "purchase",
    "amount": "100"
    }
    }
    ●internal server error?
    you need equal in line 25 ↓
    responseObject['headers'] = {}
    and check typos
    .
    Thanks!

    • @BeABetterDev
      @BeABetterDev  5 ปีที่แล้ว

      Thank you for the catch!

  • @kishor777
    @kishor777 4 ปีที่แล้ว +4

    I love 10 mins tutorial and this one is perfect 10 min tutorial. Thanks.

    • @BeABetterDev
      @BeABetterDev  4 ปีที่แล้ว +1

      Thanks so much kishor!

  • @dileepdamodaran5573
    @dileepdamodaran5573 4 ปีที่แล้ว +2

    No stories , to the point , Thank you ! Subscribed

    • @BeABetterDev
      @BeABetterDev  4 ปีที่แล้ว +1

      Thanks dileep! And welcome to the channel :)

  • @richard_franks
    @richard_franks 3 ปีที่แล้ว +7

    Thanks a ton for your tutorial here. I just needed a quick rundown and this is exactly what I needed. Quick and concise.

  • @kaiser_the_emperor
    @kaiser_the_emperor 3 ปีที่แล้ว +2

    Great work! Appreciate you showing the event structure right at the beginning which is usually skipped by many.

  • @heikg
    @heikg 3 ปีที่แล้ว +2

    Love this video. If only they gave examples like that in the official documentation, instead of just dry theory

    • @BeABetterDev
      @BeABetterDev  3 ปีที่แล้ว +1

      Thanks for the kind words heikg. I'm glad you found it helpful :)

  • @TheLostBijou
    @TheLostBijou 3 ปีที่แล้ว +1

    It could use updating, as AWS has changed its API Gateway UI substantially. GREAT WORK, THANKS!

    • @BeABetterDev
      @BeABetterDev  3 ปีที่แล้ว +1

      Thanks for pointing this out Kent! Time for a new video :)

    • @TheLostBijou
      @TheLostBijou 3 ปีที่แล้ว

      Go for it! If you need any help, I volunteer!

  • @praveendumpala5672
    @praveendumpala5672 4 ปีที่แล้ว +1

    It was great to see and understand the basic flow with API Gateway + Lambda, thanks.

  • @hhhhhhhhhhhhhhhh3484
    @hhhhhhhhhhhhhhhh3484 3 ปีที่แล้ว +6

    Great tutorial. Explained better than even AWS official ones.
    One suggestion: Next time show how you debug the error also. I get that you use cloud trail here but it'll still be useful to newcomers

    • @BeABetterDev
      @BeABetterDev  3 ปีที่แล้ว +2

      Thank you Harsha for the kind words and the feedback!

    • @timothyle4820
      @timothyle4820 ปีที่แล้ว

      @@BeABetterDev What was the fix to that error anyway?

  • @davidk7212
    @davidk7212 ปีที่แล้ว

    Very efficient, straight to the point, extremely helpful. Thank you.

  • @WesDoyle
    @WesDoyle 4 ปีที่แล้ว +2

    Great video! Thanks for demonstrating API Gateway + Lambda integration

  • @parthapaul1249
    @parthapaul1249 2 ปีที่แล้ว

    Thanks a lot🙏🙏
    Before watching this, I watched a couple of videos on lambda function, but still I couldn't understand what the hell lambda function is, you made it very clear...

  • @branstark3622
    @branstark3622 4 ปีที่แล้ว +3

    Great video, no only this but all the others in the channel too. I dont like the sounds with the mouth when starting new words, but anyway best AWS channel in youtube so far.

    • @BeABetterDev
      @BeABetterDev  4 ปีที่แล้ว

      Thanks for the feedback!

  • @vladventura1928
    @vladventura1928 4 ปีที่แล้ว +2

    Man but like how good is this video?? You're insane! Thanks a lot! I was looking for something like this for a small learning project I have in mind with flutter and aws (just to learn aws because tbh its pretty daunting to me). Thanks a lot again!!

    • @BeABetterDev
      @BeABetterDev  4 ปีที่แล้ว

      Thank you so much for such a kind comment, I really appreciate it!

  • @philipackerley5775
    @philipackerley5775 3 ปีที่แล้ว +1

    Superb intro to using the API gateway, good tutoring skills!

  • @SabbirAhmed-ev4rz
    @SabbirAhmed-ev4rz ปีที่แล้ว

    thanks man for this amazing video
    it helped me in completing my internship task
    keep up the good work

  • @shivavemula5300
    @shivavemula5300 หลายเดือนก่อน

    Very simple explanation to the point .

  • @vu3gwn
    @vu3gwn 3 ปีที่แล้ว +1

    Good one. To the point. Simple. Best way to dive in.

  • @musejama8684
    @musejama8684 3 ปีที่แล้ว +2

    Thank you bro for keeping it clean and simple. I love it.

    • @BeABetterDev
      @BeABetterDev  3 ปีที่แล้ว

      Thanks Muse! Really appreciate the kind words.

  • @mrrobot6320
    @mrrobot6320 4 ปีที่แล้ว +8

    Short and Simple. Best tutorials. Keep Teaching :). Thank you

  • @jiyongwang2459
    @jiyongwang2459 2 ปีที่แล้ว +1

    Great tutorial. Helped me on how to handle event with python. I am using a Lambda function to perform Geocode and REST API for client to invoke the API

  • @phen2841
    @phen2841 2 ปีที่แล้ว +2

    What a fantastic tutorial! Great job!

  • @hasmize
    @hasmize 2 ปีที่แล้ว

    Thanks man. I am new to Cloud but somehow I managed to secure somewhat senior position as AWS DevOps Engineer and now facing the music. I came across a similar requirement, Thanks for the help Sir

  • @humayunakhtar9515
    @humayunakhtar9515 4 ปีที่แล้ว +1

    Amazingly great and simple to get point. Salute

    • @BeABetterDev
      @BeABetterDev  4 ปีที่แล้ว

      Thank you so much for your kind words!

  • @didismit1766
    @didismit1766 5 ปีที่แล้ว +1

    Wow, everything I needed put together in one video!! Thanks alot bro!

    • @BeABetterDev
      @BeABetterDev  5 ปีที่แล้ว

      You are very welcome didi!

  • @st3114rr
    @st3114rr 3 ปีที่แล้ว +1

    Thanks so much for this awesome tutorial! Really clear and well-paced.

  • @erikngigi
    @erikngigi 4 หลายเดือนก่อน

    Excellent Tutorial. I'm currently learning how to use AWS Lambda and AWS API gateway to create a serverless USSD with Africa's Talking using python. Ideally I want to automate the entire process using Terraform.

  • @rkumarjay
    @rkumarjay 4 ปีที่แล้ว

    thanks. simple enough to get started with API gateway and integration points

  • @vanmathivelmurugan1814
    @vanmathivelmurugan1814 3 ปีที่แล้ว +2

    I am using the same code that yu gave .. but facing key error.
    Error:
    {
    "errorMessage": "'queryStringParameters'",
    "errorType": "KeyError",
    "stackTrace": [
    [
    "/var/task/lambda_function.py",
    9,
    "lambda_handler",
    "transactionId = event['queryStringParameters']['transactionId']"
    ]
    ]
    }
    Input: transactionId=1&type=abc&amount=123

  • @andressapatanga9481
    @andressapatanga9481 3 ปีที่แล้ว +1

    Gracias, me has salvado la vida compadre, desde Ecuador.

  • @samjones4327
    @samjones4327 2 ปีที่แล้ว

    Excellent tutorial! Thank you very much! I am enjoying your channel a lot. I'm just starting out with AWS but I'm super curious about how things work and you're becoming my one stop shopping channel! Cheers!

  • @xammocoloniax
    @xammocoloniax 2 ปีที่แล้ว +2

    As others already mentioned --- what's the fix for the line 25 syntax error that you said you'd get back to?

  • @kyleesposito6672
    @kyleesposito6672 3 ปีที่แล้ว +2

    OMG, thank you sooooo much for this video!!! Building a simple website for my wedding in a few months and wanted to be able for folks to RSVP online and the data loaded to a dynamoDB server to keep everything organized. Spent literally all day yesterday going thru guides and documentation with no success. Would just be curious if you would need to do anything differently for a post method instead of get. Web design is not my forte, which is why I wanted this project to challenge myself. Thanks again!!!

    • @BeABetterDev
      @BeABetterDev  3 ปีที่แล้ว +2

      Hi Kyle! Thanks for watching and congratulations on your wedding. I'm also getting married soon and hope you're able to have a happy day despite covid.
      In terms of your question, the only difference is that you would select the POST method during the api creation in API gateway. Also, the location of the parameters being passed into your lambda function will change (they will likely no longer be in the query param's field, but instead in the 'body'). The quickest way to find out where is just to console.log the input object (event) and find out where in the object the param's are being passed.
      Hope this helps and feel free to reach out if you have any followup Q's.

  • @taekhwanoh4268
    @taekhwanoh4268 3 ปีที่แล้ว +5

    When I go to url, it only shows me the message which is "Hello from Lambda!" instead of showing all the json. Does anyone know how to fix this?

  • @marco114
    @marco114 2 ปีที่แล้ว

    Thanks for the tutorial. This helped me resolve an error I was getting.

  • @ajith_e
    @ajith_e ปีที่แล้ว

    Simple and Effective, as always!!

  • @nitesh2k6
    @nitesh2k6 4 ปีที่แล้ว +1

    Woow it is very nice explanation with example .. it help me to understand API with Lambda..
    Thanks

  • @zrqx
    @zrqx ปีที่แล้ว

    That was a concise tutorial. Thank you

  • @ardikasulistija6574
    @ardikasulistija6574 2 ปีที่แล้ว +2

    Getting the following error when I tested the lambda function (without using the API gateway endpoint):
    {
    "errorMessage": "'queryStringParameters'",
    "errorType": "KeyError",
    "stackTrace": [
    [
    "/var/task/lambda_function.py",
    7,
    "lambda_handler",
    "transactionId = event['queryStringParameters']['transactionId']"
    ]
    ]
    Any insight on how to fix this? Not sure how everyone is able to use the same code... Seems like there is an issue with the code itself.

    • @BeABetterDev
      @BeABetterDev  2 ปีที่แล้ว +1

      Hi there, have you tried to print out the event that has been passed into the lambda function to see if the input contains query string parameter's. It seems like your functions code is trying to access that field but it is not present in the event. One other possibility is that you created a post API instead of a GET API. This will result in the payload been inside the body of the request instead of query string parameter's. Hope this helps.

  • @liochon4417
    @liochon4417 3 ปีที่แล้ว +1

    to-the-point. Thx. Keep up the good work!

  • @legoman01
    @legoman01 2 ปีที่แล้ว +1

    Good tutorial. Tested and it works

  • @Hackenbaker
    @Hackenbaker 3 ปีที่แล้ว

    Very well explainations. Good for a starting point. Thanks a lot.

  • @gopalakrishnanp2046
    @gopalakrishnanp2046 ปีที่แล้ว

    Great explanation and good demo

  • @amitkarmakar6418
    @amitkarmakar6418 3 ปีที่แล้ว

    Best Tutorial. You made it so simple. Thank You

  • @arunelangovan7222
    @arunelangovan7222 4 ปีที่แล้ว +2

    Well Explained. Simply Awesome. :)

  • @vijay3107
    @vijay3107 2 ปีที่แล้ว

    Wow wow wow, made it very easy and understandable. thanks

  • @gordonbrown3716
    @gordonbrown3716 3 ปีที่แล้ว +1

    NIce tutorial on api and lamda function

  • @paulking1796
    @paulking1796 3 ปีที่แล้ว +1

    Thanks a lot, this was really helpful!!!!! Have a nice day :)

    • @BeABetterDev
      @BeABetterDev  3 ปีที่แล้ว

      You're very welcome paul, and you too!

  • @morenoaf
    @morenoaf ปีที่แล้ว +1

    Great explanation

  • @LuvxJacqu4li8e
    @LuvxJacqu4li8e ปีที่แล้ว

    Nice. Just in time. I just got done with Fast API.

  • @squirrel1620
    @squirrel1620 3 ปีที่แล้ว +3

    In our use case, we built an API Gateway to call a collection of microservices, from lambda(new code) & HTTP (legacy code). It works well, but I'd advise anyone working on a serverless architecture to look into how to keep lambdas "warm"

    • @BeABetterDev
      @BeABetterDev  3 ปีที่แล้ว

      Good advice Derek, Provisioned Concurrency is a life saver!

  • @felixvanderspek1293
    @felixvanderspek1293 3 ปีที่แล้ว +2

    a cool little trick to use if you want to print a variable name and its value is to do (with transaction_id as example): print(f'{transaction_id=}')

    • @BeABetterDev
      @BeABetterDev  3 ปีที่แล้ว +1

      Thanks for this cool tip Felix!

  • @beatalert123
    @beatalert123 11 หลายเดือนก่อน

    Awesome video..!! I am planning to create ETL data pipes using lambda + API gateway and then use step functions or MWAA to orchestrate the Lambda.

  • @rahulmarkonda
    @rahulmarkonda 2 ปีที่แล้ว +1

    Nice and fast. Thanks.

    • @BeABetterDev
      @BeABetterDev  2 ปีที่แล้ว

      You're very welcome Raul!

  • @ashokgVideo
    @ashokgVideo 4 ปีที่แล้ว +1

    To the point video. Appreciate it.

  • @devprakash5320
    @devprakash5320 3 ปีที่แล้ว

    very well explained . Thanks for the video

  • @prannoyroy5312
    @prannoyroy5312 ปีที่แล้ว +1

    Great video. One doubt I faced at work. How do you choose between having one big lambda function with Flask Python code internally handling all the routing for different endpoint v/s one seperate Python lambda(without Flask) for each Api gateway resource? Which is a better design and better performing?

  • @sanrise27
    @sanrise27 4 ปีที่แล้ว +1

    Great stuff!! Thanks a lot for the overview!!👍🏼

  • @vpshibin
    @vpshibin 2 ปีที่แล้ว +3

    Great video. One small point. You mentioned about a syntax error in line 25, but doesn’t address that later in the video.

    • @timothyle4820
      @timothyle4820 ปีที่แล้ว

      What was the actual fix to that error anyway?

    • @ymahtab
      @ymahtab ปีที่แล้ว +1

      @@timothyle4820 he missed out an equals character before the empty dictionary. I think he simply fixed it off screen.

    • @arunshankars8398
      @arunshankars8398 ปีที่แล้ว

      @@timothyle4820 Just add the = symbol before the {}

  • @sateeshkumarchillakuru4222
    @sateeshkumarchillakuru4222 3 ปีที่แล้ว +1

    Let me try ,..happy to get this video

    • @BeABetterDev
      @BeABetterDev  3 ปีที่แล้ว

      Thanks Sateesh. Were you able to create your API?

  • @shraddhasable5416
    @shraddhasable5416 2 ปีที่แล้ว +1

    thanks for sharing...it was really helpful.

  • @geostrategicinsights6801
    @geostrategicinsights6801 3 ปีที่แล้ว +1

    Thank you so much! This was tremendously helpful!

  • @mustaphag
    @mustaphag 3 ปีที่แล้ว +1

    Excellent work

  • @cstanleyhns
    @cstanleyhns 2 ปีที่แล้ว

    Well presented. Would be good to see the API Gateway raise an event to Event bridge and then Event bridge match to the Lambda and return the same way.

  • @go_sh4627
    @go_sh4627 9 หลายเดือนก่อน

    I love this, this is very straight forward. But as a beginner in the field of AWS I just want a clarification. The method you used, why GET and not POST method?

  • @reddylakshmi8071
    @reddylakshmi8071 2 ปีที่แล้ว +1

    Really ur videos r so good

  • @Bigshotdata
    @Bigshotdata 2 ปีที่แล้ว

    Great video super insightful thanks!

  • @zhongdaochen8221
    @zhongdaochen8221 2 ปีที่แล้ว

    Fantastic video, many thanks!

  • @sachinpc702
    @sachinpc702 4 ปีที่แล้ว +2

    Great job with the video

  • @venkatbubly
    @venkatbubly 3 ปีที่แล้ว +1

    Great start, thank you for the video. Just asking, how did it worked for you without a = in responseObject['headers'] = {}?

    • @BeABetterDev
      @BeABetterDev  3 ปีที่แล้ว +1

      Hi Venkatesh,
      You have a very fine eye :) I believe I corrected this during the video editing process. The code link should contain the corrected code.
      Daniel

  • @TomerBenDavid
    @TomerBenDavid 5 ปีที่แล้ว +1

    Splendid 👌more videos please

  • @alaaeddinekolli4178
    @alaaeddinekolli4178 ปีที่แล้ว

    Magnifique ! thanks for this tutorial

  • @vijeandran
    @vijeandran 2 ปีที่แล้ว +1

    Nice video

  • @bradchellingworth2002
    @bradchellingworth2002 4 ปีที่แล้ว +1

    Very nice tutorial. New subscriber here :)

    • @BeABetterDev
      @BeABetterDev  4 ปีที่แล้ว

      Thanks Brad! Welcome to the channel :)

  • @kashif3683
    @kashif3683 4 ปีที่แล้ว +1

    Wow! It was simple! Thanks.

  • @egehanyorulmaz4965
    @egehanyorulmaz4965 ปีที่แล้ว

    Straight to the point. Thank you. I was wondering how we could add an authentication to the request as well. My request returns Missing Authentication Token. I don't want to make the API public as it is sending a separate request to a paid API.

  • @franktumminello9166
    @franktumminello9166 2 ปีที่แล้ว

    Great video!

  • @drazaie
    @drazaie ปีที่แล้ว

    Great video! Looks like queryStringParameters doesnt work in AWS with the new Python 3.10. Any ideas how to correct this?

  • @ladynobug8759
    @ladynobug8759 3 ปีที่แล้ว +1

    Thanks, great content!

  • @EdeYOlorDSZs
    @EdeYOlorDSZs 2 ปีที่แล้ว +1

    Cool video but I get an internal server error saying it doesn't recognise 'queryStringParameters' I have no idea how to fix it after a few hours

    • @BeABetterDev
      @BeABetterDev  2 ปีที่แล้ว

      Hi there, did you use a GET method ?

  • @joedunder4439
    @joedunder4439 ปีที่แล้ว

    Thanks! Very helpful.

  • @fT_amer
    @fT_amer 7 หลายเดือนก่อน

    Thank you for this one

  • @LocdnessMomster
    @LocdnessMomster 2 ปีที่แล้ว

    How would a client access this programmatically?

  • @prasaianooz
    @prasaianooz 4 ปีที่แล้ว +1

    brilliant! are you using vim keybindings in sublime ? I would love to see some vim tuts aswell

    • @kawong808
      @kawong808 3 ปีที่แล้ว

      does anyone know how to get vim in sublime???

  • @ankitmishra7166
    @ankitmishra7166 2 ปีที่แล้ว

    Thanks for the video, it actually helped in solving my entire problem.
    One question though, here the transactionResponse is like 1:1 mapping. how bout if function has a loop, and it returns more than 1 value, in that case how to get multiple values in a response object

    • @arunshankars8398
      @arunshankars8398 ปีที่แล้ว

      You can create several key value pairs in json. You could also consider using a list as the value in json.

  • @generichuman_
    @generichuman_ 2 ปีที่แล้ว

    Shouldn't line 20 in the code be responseObject['headers'] = {}?

  • @StephenRayner
    @StephenRayner 3 ปีที่แล้ว

    I create my APIGs via terraform, the concept of stages feels pointless as I have my production and staging environments on different AWS accounts.
    I do have multiple stage environments on one account; dev, qat, uat, pen. But these are setup as different resources in terraform where I use the workspaces feature to divide the different stages.
    Do you agree that stages feel useless for the described use case? Any advise is appreciated.

  • @ManjunathManja1227
    @ManjunathManja1227 3 ปีที่แล้ว +1

    Great video. But how to protect this api endpoint?

    • @BeABetterDev
      @BeABetterDev  3 ปีที่แล้ว

      Hi Manjunath! Great question! I actually have a new video coming out on this exact topic in the next week or so. Stay tuned!

  • @marcelogrsp
    @marcelogrsp 3 ปีที่แล้ว +1

    I think there is a typo in responseObject[‘headers’] {}

  • @jasper5016
    @jasper5016 2 ปีที่แล้ว +1

    Thanks so much.

  • @kathirjay9168
    @kathirjay9168 2 ปีที่แล้ว

    Informative video : how about also including how to troubleshoot errors . Get a "message" : "Internal server error" when hitting the API URL

  • @sraj7284
    @sraj7284 ปีที่แล้ว

    Hi, Thank you, this de-mystified some of the profoundness of the topic! Very well structured and explained... What is throwing me off, is whether there is a standard structure protocol for the event[] object? Similarly, why cant a straighforward JSON response be sent over through the lambda? Again, is there a standard structure for this responseObject[]? How and where is this responseObject declared?
    Why can't the lamda return something like so:
    return {
    'statusCode': 200,
    'body': json.dumps('Hello from Lambda!'),
    'Name1':event['queryStringParameters']['param1']
    'Name2':event['queryStringParameters']['param2']
    }

  • @prafullprajapati3643
    @prafullprajapati3643 3 ปีที่แล้ว

    Can we build API gateway to send emails from SES without using Lambda

  • @adarshhegde6839
    @adarshhegde6839 2 ปีที่แล้ว

    I am new to AWS and API, Is there a video where I can learn to make external API Calls using Lambda?
    Thanks