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

Поділитися
Вставка
  • Опубліковано 5 січ 2025

КОМЕНТАРІ • 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 роки тому +98

    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

    • @ZacheryBlakeDavis
      @ZacheryBlakeDavis Рік тому

      254k 😮

    • @ymahtab
      @ymahtab Рік тому

      @@ZacheryBlakeDavis 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!

  • @learndevtech
    @learndevtech 8 місяців тому

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

  • @BilalAhmed-nt9gi
    @BilalAhmed-nt9gi 4 роки тому +9

    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!

  • @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!

  • @dileepdamodaran5573
    @dileepdamodaran5573 4 роки тому +2

    No stories , to the point , Thank you ! Subscribed

    • @BeABetterDev
      @BeABetterDev  4 роки тому +1

      Thanks dileep! And welcome to the channel :)

  • @kishor777
    @kishor777 4 роки тому +4

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

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

  • @shivavemula5300
    @shivavemula5300 2 місяці тому

    Very simple explanation to the point .

  • @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!

  • @erikngigi
    @erikngigi 5 місяців тому

    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.

  • @praveendumpala5672
    @praveendumpala5672 4 роки тому +1

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

  • @philipackerley5775
    @philipackerley5775 3 роки тому +1

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

  • @richard_franks
    @richard_franks 4 роки тому +7

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

  • @SabbirAhmed-ev4rz
    @SabbirAhmed-ev4rz Рік тому

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

  • @WesDoyle
    @WesDoyle 4 роки тому +2

    Great video! Thanks for demonstrating API Gateway + Lambda integration

  • @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 2 роки тому

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

  • @davidk7212
    @davidk7212 Рік тому

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

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

  • @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!

  • @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?

  • @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!

  • @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 :)

  • @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

  • @vu3gwn
    @vu3gwn 3 роки тому +1

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

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

  • @beatalert123
    @beatalert123 Рік тому

    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.

  • @taekhwanoh4268
    @taekhwanoh4268 4 роки тому +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?

  • @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

  • @phen2841
    @phen2841 2 роки тому +2

    What a fantastic tutorial! Great job!

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

  • @mrrobot6320
    @mrrobot6320 4 роки тому +8

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

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

  • @humayunakhtar9515
    @humayunakhtar9515 4 роки тому +1

    Amazingly great and simple to get point. Salute

    • @BeABetterDev
      @BeABetterDev  4 роки тому

      Thank you so much for your kind words!

  • @musejama8684
    @musejama8684 4 роки тому +2

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

    • @BeABetterDev
      @BeABetterDev  4 роки тому

      Thanks Muse! Really appreciate the kind words.

  • @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

  • @ajith_e
    @ajith_e Рік тому

    Simple and Effective, as always!!

  • @didismit1766
    @didismit1766 5 років тому +1

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

  • @liochon4417
    @liochon4417 3 роки тому +1

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

  • @rkumarjay
    @rkumarjay 4 роки тому

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

  • @InfantGerald
    @InfantGerald Рік тому +1

    Thanks

    • @BeABetterDev
      @BeABetterDev  Рік тому

      Thank you so much for your generosity!

  • @legoman01
    @legoman01 2 роки тому +1

    Good tutorial. Tested and it works

  • @st3114rr
    @st3114rr 3 роки тому +1

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

  • @marco114
    @marco114 2 роки тому

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

  • @zrqx
    @zrqx Рік тому

    That was a concise tutorial. Thank you

  • @LuvxJacqu4li8e
    @LuvxJacqu4li8e 2 роки тому

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

  • @amitkarmakar6418
    @amitkarmakar6418 3 роки тому

    Best Tutorial. You made it so simple. Thank You

  • @nitesh2k6
    @nitesh2k6 4 роки тому +1

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

  • @vijay3107
    @vijay3107 2 роки тому

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

  • @gopalakrishnanp2046
    @gopalakrishnanp2046 Рік тому

    Great explanation and good demo

  • @andressapatanga9481
    @andressapatanga9481 3 роки тому +1

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

  • @arunelangovan7222
    @arunelangovan7222 4 роки тому +2

    Well Explained. Simply Awesome. :)

  • @Hackenbaker
    @Hackenbaker 3 роки тому

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

  • @morenoaf
    @morenoaf Рік тому +1

    Great explanation

  • @rahulmarkonda
    @rahulmarkonda 2 роки тому +1

    Nice and fast. Thanks.

  • @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 ?

  • @sanrise27
    @sanrise27 4 роки тому +1

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

  • @alaaeddinekolli4178
    @alaaeddinekolli4178 Рік тому

    Magnifique ! thanks for this tutorial

  • @gordonbrown3716
    @gordonbrown3716 4 роки тому +1

    NIce tutorial on api and lamda function

  • @generichuman_
    @generichuman_ 2 роки тому

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

  • @ashokgVideo
    @ashokgVideo 4 роки тому +1

    To the point video. Appreciate it.

  • @drazaie
    @drazaie Рік тому

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

  • @devprakash5320
    @devprakash5320 3 роки тому

    very well explained . Thanks for the video

  • @前田幸洋-b1u
    @前田幸洋-b1u 3 роки тому +3

    05:42 In my case, "=" is required at line 25.

    • @BeABetterDev
      @BeABetterDev  3 роки тому +1

      Thank you for pointing this out!

    • @klayliu3078
      @klayliu3078 3 роки тому

      Thanks, your answer fixed my error.
      [ERROR] Runtime.UserCodeSyntaxError: Syntax error in module 'lambda_function': invalid syntax (lambda_function.py, line 25)
      Traceback (most recent call last):
      File "/var/task/lambda_function.py" Line 25
      responseObject['headers']{}
      --------------------------
      line 25 should be:
      responseObject['headers'] {} ==> responseObject['headers'] = {}

    • @kediboneramoloko3441
      @kediboneramoloko3441 3 роки тому +1

      @@klayliu3078 Hi, Is your response the same as his? my returns -->{
      "errorMessage": "'queryStringParameters'",
      "errorType": "KeyError",
      "stackTrace": [
      [
      "/var/task/lambda_function.py",
      7,
      "lambda_handler",
      "transactionId = event['queryStringParameters']['transactionId']"
      ]
      ]
      }

  • @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!

  • @sateeshkumarchillakuru4222
    @sateeshkumarchillakuru4222 3 роки тому +1

    Let me try ,..happy to get this video

    • @BeABetterDev
      @BeABetterDev  3 роки тому

      Thanks Sateesh. Were you able to create your API?

  • @mustaphag
    @mustaphag 3 роки тому +1

    Excellent work

  • @hunqiangng2511
    @hunqiangng2511 Рік тому

    Hi , I would like to ask how to assign static ip address to APIGW ?

  • @franktumminello9166
    @franktumminello9166 2 роки тому

    Great video!

  • @reddylakshmi8071
    @reddylakshmi8071 2 роки тому +1

    Really ur videos r so good

  • @marcelogrsp
    @marcelogrsp 3 роки тому +1

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

  • @zhongdaochen8221
    @zhongdaochen8221 3 роки тому

    Fantastic video, many thanks!

  • @geostrategicinsights6801
    @geostrategicinsights6801 4 роки тому +1

    Thank you so much! This was tremendously helpful!

  • @AllenAcosta-o6g
    @AllenAcosta-o6g Рік тому

    Can someone please explain how the output that was returned (in the browser) was formatted with a : following the transactionID, type, amount and message and a " " surrounding 5, PURCHASE, 500 and Hello from Lambda land ? I don't see any formatting in the code related to the formatting in the output.

    transactionID: "5"
    type: "PURCHASE"
    amount: "500"
    message: "Hello from Lambda land"

    Thank you in advance.

  • @LocdnessMomster
    @LocdnessMomster 2 роки тому

    How would a client access this programmatically?

  • @georgia-pro7357
    @georgia-pro7357 3 роки тому +1

    Thanks Dan , if i want lambda to run query against mysql db , then retrieve results in json format or do crud on db using lambda and api ,, how is that possible ?

    • @BeABetterDev
      @BeABetterDev  3 роки тому

      Hi Georgia!
      You can do this by combining the contents of this tutorial with these two other videos on how to set up a RDS MySQL DB + How to query it from Lambda.
      Hope this helps!
      ua-cam.com/video/Ng_zi11N4_c/v-deo.html and ua-cam.com/video/vyLvmPkQZkI/v-deo.html

  • @shraddhasable5416
    @shraddhasable5416 2 роки тому +1

    thanks for sharing...it was really helpful.

  • @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=}')

  • @Bigshotdata
    @Bigshotdata 2 роки тому

    Great video super insightful thanks!

  • @BigB12
    @BigB12 4 роки тому

    How can I check status of rds instance is running or not using python script

  • @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

  • @sachinpc702
    @sachinpc702 4 роки тому +2

    Great job with the video

  • @karikalanramakrishnan9286
    @karikalanramakrishnan9286 3 роки тому

    Getting the syntax error on responseObject['headers'] {} as mentioned on video, not sure how to fix this pls?

    • @BeABetterDev
      @BeABetterDev  3 роки тому

      Hi there,
      See comments section - many folks have corrected the issue!

  • @vijeandran
    @vijeandran 2 роки тому +1

    Nice video

  • @gulshan5957
    @gulshan5957 3 роки тому

    very helpful. just a query that i want to understand the code so can you provide me with any link which could help me understanding the code

  • @s0ulseek3r
    @s0ulseek3r Рік тому +1

    There's a '=' missing in the code: responseObject['headers'] = {}

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

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

  • @go_sh4627
    @go_sh4627 10 місяців тому

    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?

  • @kailashlalchaudhary3867
    @kailashlalchaudhary3867 4 роки тому +1

    If we are getting Json inputs from front end then how we can handle it using Lambda funtion+API gateway and I need to store that data in RDS instance in table form

    • @BeABetterDev
      @BeABetterDev  4 роки тому +1

      Good question - stay tuned for an upcoming video on the topic!

  • @gayathrijanardhanan4551
    @gayathrijanardhanan4551 4 роки тому

    I'm getting this message "Function not found: arn:aws:lambda:us-east-1:313987576106:function:TransactionProcessor"
    And "Internal server" when continued. What could be the reason? I've carefully gone through all the steps

    • @BeABetterDev
      @BeABetterDev  4 роки тому

      Hi Gayathri,
      Are you sure that you have created a Lambda function called TransactionProcessor? Also, can you check to make sure it is indeed in us-east-1?

    • @gayathrijanardhanan4551
      @gayathrijanardhanan4551 4 роки тому

      @@BeABetterDev Function creation successful.👍🏻 But still I'm getting internal server error while invoking the url

    • @BeABetterDev
      @BeABetterDev  4 роки тому +1

      Hi Gayathri. Are you able to check the logs of your invocation to see where it is failing? They should be available by going to the monitoring section of your lambda.

    • @gayathrijanardhanan4551
      @gayathrijanardhanan4551 4 роки тому +1

      @@BeABetterDev Thank you for the tutorial and quick response to queries. Thank you!

    • @BeABetterDev
      @BeABetterDev  4 роки тому

      You're very welcome!

  • @anishsahu6023
    @anishsahu6023 4 роки тому +1

    I am not getting response when I used invoke url with transaction details.
    It Only display "hello from lambda"

    • @betci148
      @betci148 4 роки тому +1

      Don't add the "transaction" resource and you should be good to go

    • @xosauce9193
      @xosauce9193 4 роки тому

      @@betci148 Im getting the same response as Anish. Do you mean we don't create a child resource? Why cant we create a child resource like in the video?

    • @MrChadWille
      @MrChadWille 4 роки тому

      @@xosauce9193 You need to deploy your lambda function. The 'hello from Lambda' is the original AWS and not your code

  • @TomerBenDavid
    @TomerBenDavid 5 років тому +1

    Splendid 👌more videos please

  • @tumblelandproduction
    @tumblelandproduction 3 роки тому +1

    What was the syntax error on line 25?

  • @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 2 роки тому

      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 {}

  • @swathychandran8213
    @swathychandran8213 4 роки тому

    while trying this the lambda functions works successfully but the deployment of API throws an error “User does not have LISTWEBACL and AssociateWEBACL persmision for Web application Firewall regional” please help

  • @krishnayaswanth2608
    @krishnayaswanth2608 3 роки тому

    Hi team I have a use case where we need to get name and ID from through 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!