AWS Lambda Python functions with a database (DynamoDB)

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

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

  • @sneanone
    @sneanone 2 года назад +12

    Great video, exactly what I needed right now. The clearest explanation I've found on AWS Lambda + DynamoDB. Please keep on making those!

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

      Thanks! Feel free to suggest any topics you'd like me to explore as well.

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

      @@pixegami I think it would be super useful if you’ve shown a standard startup setup Python Lambda + S3 + DynamoDB + SQS/SNS. There are no tutorials that goes through a simple full web app workflow. Thanks for the content

  • @canopy28
    @canopy28 Год назад +4

    This is the only and most helpful aws + lambda + dynamodb + python tutorial on youtube. Like literally youre the only one that shows and explains also the inbetween stuff and the only one where all the above mentioned components are all together shown! Thank you so much !

    • @pixegami
      @pixegami  11 месяцев назад

      Thanks! I'm glad you enjoyed it and found it useful :) It's why I make these!

  • @FERNANOMT5
    @FERNANOMT5 10 месяцев назад +1

    This is by far one of the best tutorials I've ever seen.
    Keep it going, Was good to make it local and the transformation to lambda and the connect with DynamoDB.
    Really like it. you got a subscriber!

    • @pixegami
      @pixegami  9 месяцев назад

      Thank you for the kind words. Glad you enjoyed it!

  • @elvincheah6412
    @elvincheah6412 Год назад +1

    Thanks for the video. I was really struggling to make a view counter using Lambda & DynamoDB until I saw this video. Appreciate the help :)

    • @pixegami
      @pixegami  11 месяцев назад +1

      That's awesome! Well done :)

  • @mkpixelsquad
    @mkpixelsquad Год назад +2

    really loved it, I am non coder still I understood almost everything because the way you explained is very clear.

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

      Great to hear! But it's a pretty technical video - what made you want to watch it as a non-coder? (I'm not gatekeeping, I'm just curious)

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

    Watching on August 22nd, 2024... thanks a lot bro!

  • @amitdagan78
    @amitdagan78 Год назад +2

    you made it so easy to understand man...
    amazing!
    pls keep it up!

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

    These videos of yours are from heaven. Thank you ;)

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

      Glad you like them!

  • @fernandocallasaca
    @fernandocallasaca 11 месяцев назад +2

    Excelent video, pls... what command you use to clean and organice the code?

    • @pixegami
      @pixegami  11 месяцев назад

      I think you mean the auto format on save? Look into “black” for Python formatting :) or “Prettier” for everything else. You can configure it in VSCode to format on save.

  • @eddieteah3102
    @eddieteah3102 Год назад +1

    Thanks for this simple video. Most aws videos are 3 hours long haha.

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

      Thanks! I think a lot of tutorials fall into the trap of trying to explain every single detail - but I think most people just care about solving a problem, so that's how I try to design my content :)

  • @Canda-fh4xc
    @Canda-fh4xc Год назад +1

    Best explanation.
    We will appreciate it, if you can make a video including S3 with DynamoDB and Lambda.
    Thank you,

    • @pixegami
      @pixegami  Год назад +1

      Thanks for the suggestion! It helps me decide what to work on next. I definitely plan on doing more Python + AWS videos in the coming months.

  • @jameslahner6791
    @jameslahner6791 9 месяцев назад +1

    Great video! Does this handle lambdas that are running concurrently?

    • @pixegami
      @pixegami  8 месяцев назад +1

      Yup, DynamoDB is pretty good at stuff like that, so it's fine with handling a ton of concurrent transactions.

  • @TheAstroengineer
    @TheAstroengineer 8 месяцев назад +1

    Neat video. Thanks for the clear explanation. If I have multiple python files to return my message should upload all those python files as a zip file? or should create those python files directly on Lambda code?

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

      I think that's a matter of choice (and it seems to be a question of how to design your infrastructure). I'd probably go with whatever option is easier to reproduce, develop with, and to automate. There's also infrastructure packages that help you to deploy Python code a lot easier: docs.aws.amazon.com/cdk/api/v1/docs/aws-lambda-readme.html#bundling-asset-code

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

      @@pixegami Thank you. I went with EC2, and linked it to REST API in AWS API Gateway. This works well for my requirements.

  • @shahzadmunir-ub5cf
    @shahzadmunir-ub5cf Год назад +1

    VERY WELL EXPLANATION

  • @mohammadnawaz3758
    @mohammadnawaz3758 Год назад +1

    Amazing, you should have way more subs!

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

      Thanks! I hope so too. One day... 🎯

  • @Klamath123456789
    @Klamath123456789 11 месяцев назад +1

    Hello, thanks for your video. What extension are you using for python please?

    • @pixegami
      @pixegami  11 месяцев назад

      In VSCode?> I'm using GitHub Copilot (see my review on it here: ruclips.net/video/tG8PPne7ef0/видео.html)
      I also use "black" for auto formatting.

  • @FrostBiteXHEduardo
    @FrostBiteXHEduardo 9 месяцев назад +1

    This tutorial is excellent! I have a question regarding a similar setup involving SQS, Lambda, and Timestream.
    I trigger Lambda each time the SQS queue accumulates approximately 100 messages. It then connects to Timestream to store some data.
    Currently, I'm using boto3.client('timestream-write', ...) within the lambda_handler() function. However, I'm starting to suspect that this approach increases execution time because it establishes a new connection each time the function is invoked.
    Is there a method to maintain database connections across multiple Lambda invocations?

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

      You can't really maintain state across multiple Lambda invocations. So the main question here is - sure, the approach you take might incur some overhead to create the connection, but have you measured it and determined that the extra latency actually matters enough for you to care about? To me, this just sounds like an acceptable trade-off of not having to maintain live servers.
      In any case, it's also useful to know that Lambda function "containers" stay alive for up to 15 minutes, including anything in its memory. That means, if you create your connection as a singleton (e.g. global variable), then any time that container gets re-used, you should be able to access that same connection without having to reconnect.

  • @saurom0lamderth
    @saurom0lamderth 7 месяцев назад +1

    I love this, thank, 😁

    • @pixegami
      @pixegami  7 месяцев назад

      Glad you enjoyed it!

  • @JimmyBagOfDonuts
    @JimmyBagOfDonuts 7 месяцев назад +1

    Thanks!

    • @pixegami
      @pixegami  6 месяцев назад

      You're welcome!

  • @michaelclemens7643
    @michaelclemens7643 Год назад +1

    Super helpful, thank you

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

    thx so much! the way you explained is very perfect!!!!!

  • @hassanrady6134
    @hassanrady6134 Год назад +1

    Hi, thank you for the video. What VS theme is that?

  • @iccherherbarium9688
    @iccherherbarium9688 Год назад +1

    Why DynamoDb access issue didn't happened when you run the .py program from CLI? But while running LAMBDA we need to add the policy. Why CLI allowed to put item without that DB policy? Please make this clear.

    • @pixegami
      @pixegami  Год назад +1

      Very good question, I'm sorry I didn't cover that. All AWS resources (including DynamoDB) need a policy to access (read, write, etc). By default, everything is secure, which means that by default-nothing has access, and it must be granted explicitly (that's the case you saw with the Lambda function).
      But when you use the CLI, you've already configured it when you installed it, probably with `aws configure`. You can check your configuration at `~/.aws/credentials` (on Unix/Mac), and that is probably linked to a User with "Admin" access, which has access to everything.
      So in both cases, a policy is necessary. In the Lambda case, you need to grant one for the Lambda's invocation role. For the CLI, you gain access via the CLI user's policy (which is probably Admin).

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

      Okay. I got it. Yes. Thank you for the clarification!!

  • @johnathanhorner6888
    @johnathanhorner6888 Год назад +1

    Are you using the AWS Lambda extension in vs code? Or the regular python extension in vs code

    • @pixegami
      @pixegami  Год назад +1

      Just the regular Python extension. But I may have also downloaded the AWS Lambda extension, I just don't think I've enabled or put effort into using it yet though.

    • @johnathanhorner6888
      @johnathanhorner6888 Год назад +1

      @@pixegami i've been following along but when i try to implement this i receive this message "errorMessage": "'visit-count-table'",
      "errorType": "KeyError",

    • @pixegami
      @pixegami  Год назад +1

      @@johnathanhorner6888 Hmm, that sounds like a problem where the table's primary key name, and the key you're trying to query it with, are different. When you go to your DDB table in the console, can you confirm the name of the primary key? Is it the same as in your code? In my code I used "user" as the key: github.com/pixegami/python-lambda-with-database/blob/main/lambda_function.py#L16
      Or if that's not it - can you share the full stack trace of where that issue occurred?

    • @johnathanhorner6888
      @johnathanhorner6888 Год назад +1

      @@pixegami yes that's what it was. But the issue I'm having now is with the counter. Everytime that i hit the test button it stays at 1 it never increases by +1.

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

      @@johnathanhorner6888 Nice, you're making progress. The counter is incremented and saved on this line: github.com/pixegami/python-lambda-with-database/blob/main/lambda_function.py#L22
      If you aren't seeing it being incremented, I think it's likely one of three scenarios:
      - The app is missing the code to update the counter (and save it to the DB).
      - There's an error in the code. If this is the case, you should be able to see errors and logs in the Lambda 'monitoring' tab.
      - The code works, but you are loading/saving the wrong user (or different users) - you can check this by inspecting your table in DDB directly.

  • @brett1234-s7f
    @brett1234-s7f Год назад +1

    hey, what's the setting to have the function declaration line appear as the top line in vscode? 13:57 for example
    thanks

    • @pixegami
      @pixegami  Год назад +1

      I think this is VSCode sticky scroll? code.visualstudio.com/updates/v1_70#_editor-sticky-scroll

    • @brett1234-s7f
      @brett1234-s7f Год назад

      @@pixegami many thanks my friend

  • @gyt7504
    @gyt7504 9 месяцев назад +1

    thanks, great explanation & demo

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

      Thanks! Glad you enjoyed it :)