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
Great video. At 2:18, you noted we could add other requirements (in my case xmltodict). Your example works and I can add xmltodict with a cdk synth. However, in my Lambda an exception is thrown that the xmltodict resource could not be found. Is this something simple?
Will you also do a video what the best way to do an integration test to hit real AWS service? Eg: Send a message to SQS which trigger a lambda function to add item in DynamoDb. How do we test this as part of integration test?
2 ปีที่แล้ว +1
Nice trick, but what about when we have to do some stuff with Aurora, DynamoDB or S3 inside the lambda function. And when is using API Gateway using Cognito Authorizers ? Will always need to set CLI session?
For the simple function used in this video, you don’t really need CDK. SAM can do everything and Sam local invoke will work too. I believe CDK is necessary when you lambda need to invoke other AWS services like s3 or dynamoDB
You can do that with CDK and SAM. Under the hood, everything is CloudFormation. I use CDK with TypeScript 99% of the time even when my lambdas are written in other languages (Python, Rust, etc.). Auto-completion, references, docs, type checks, and so on in TS is absolutelly a time saver (+ the benefit of using OOP for yor resources).
What if the lambda connected to dynamo db ? will be connected to the AWS DynamoDB or we need to connect have local dynamo db instance up and running in this case ?
Excelent. I needed this. Thanks. Could you please make a video about awssdkcalls with cdk python? I’m having a hard time understanding how to find the different information about it.
Nice tutorial. Can you make simialar to this but this time how to debug cdk app (python) with context (for example -c stage=prepord) in visual studio code? How correctly setup lunch.json?
Thanks for the video! For real life scenario, how do you run this for multiple microservices with API gateway? I ask because I want to unify all my IaaC to CDK but the in ability to test locally stops me from doing that. Serverless framework + serverless-offline plugin does this very easily.
Do you recommend this process for building step functions? I would think since the step function new visual editor generates a json definition file it’s easy enough to through into version control. Then you can use this to test individual lambdas within the step function locally. Does that makes sense? Or is there a way to use the json definition in this framework without any cdk and still have it included in deployments?
This is good for basic lambdas but usually when you have to deal with other stuff such as SSM parameters, it becomes really dificult to test it this way, in my own experience.
Check out Moto python library. It allows for mocking AWS resources locally, as a server or at runtime. So you can mock SSM, etc...I think it's a far better way than using Sam, Docker, etc....way less complicated to use Moto, and Moto support is amazing, they will even take your code if something doesn't work and try to help you out and set up a project to check out any issue.
This is a SAM specific feature, there are some libraries out there that try to fix this issue but I haven't seen anything good for complex scenarios yet. I'd normally stick to a simple test file where I import my app.py/index.js/index.ts file and call the handler with a test event. Pretty simple but so far I have had great results.
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
Man doesn't miss. I was reading the blog post by amazon for this like a week ago and you already have a video..
That was very useful. I didn't know that you can do this! Thank you. Here I was testing my lambdas via the lamba management console like a noob
really nice. i'm wondering how i can integrate my lambda layers with this.
Need to RTFM a bit
A great video. Always wanted to test lambda locally.
Just use plain unit testing and mock remote resources - it will be much faster. At least for me, it works better than sam-local.
Great video, very clear and easy to follow!
Thank you
Great video. At 2:18, you noted we could add other requirements (in my case xmltodict). Your example works and I can add xmltodict with a cdk synth. However, in my Lambda an exception is thrown that the xmltodict resource could not be found. Is this something simple?
Will you also do a video what the best way to do an integration test to hit real AWS service? Eg: Send a message to SQS which trigger a lambda function to add item in DynamoDb. How do we test this as part of integration test?
Nice trick, but what about when we have to do some stuff with Aurora, DynamoDB or S3 inside the lambda function. And when is using API Gateway using Cognito Authorizers ? Will always need to set CLI session?
Is it possible to test locally via sam if os.environ is added to the code e.g. DB_HOST, DB_PORT for function env variables?
That was really helpful man, thank you
You're very welcome
This is very good . Thanks for this video
You're very welcome!
Your videos are in a class of their own! Thanks for teaching! @5:05 😂 I have been there too 🤣
For the simple function used in this video, you don’t really need CDK. SAM can do everything and Sam local invoke will work too. I believe CDK is necessary when you lambda need to invoke other AWS services like s3 or dynamoDB
You can do that with CDK and SAM. Under the hood, everything is CloudFormation. I use CDK with TypeScript 99% of the time even when my lambdas are written in other languages (Python, Rust, etc.). Auto-completion, references, docs, type checks, and so on in TS is absolutelly a time saver (+ the benefit of using OOP for yor resources).
Great video. Is there a link to docs for this? Looking for the javascript-specific implementation.
What if the lambda connected to dynamo db ? will be connected to the AWS DynamoDB or we need to connect have local dynamo db instance up and running in this case ?
Thank you for this.
Excelent. I needed this. Thanks. Could you please make a video about awssdkcalls with cdk python?
I’m having a hard time understanding how to find the different information about it.
Nice tutorial. Can you make simialar to this but this time how to debug cdk app (python) with context (for example -c stage=prepord) in visual studio code? How correctly setup lunch.json?
serverless is also a good tool for aws lambdas
Thanks for the video! For real life scenario, how do you run this for multiple microservices with API gateway? I ask because I want to unify all my IaaC to CDK but the in ability to test locally stops me from doing that. Serverless framework + serverless-offline plugin does this very easily.
Good question. Please share the answer if you know how to do it
@@0xccd My solution is to keep using Serverless framework + serverless-offline plugin.
Do you recommend this process for building step functions? I would think since the step function new visual editor generates a json definition file it’s easy enough to through into version control. Then you can use this to test individual lambdas within the step function locally. Does that makes sense? Or is there a way to use the json definition in this framework without any cdk and still have it included in deployments?
if you are using websocket this doesn't work - try to make the decoupled enough so the websocket dependency is not a must
Thanks.
This is good for basic lambdas but usually when you have to deal with other stuff such as SSM parameters, it becomes really dificult to test it this way, in my own experience.
Check out Moto python library. It allows for mocking AWS resources locally, as a server or at runtime. So you can mock SSM, etc...I think it's a far better way than using Sam, Docker, etc....way less complicated to use Moto, and Moto support is amazing, they will even take your code if something doesn't work and try to help you out and set up a project to check out any issue.
@@kcrikk5818 I’ll give it a try. Thanks
keep in mind that you have to install aws-cdk.aws-lambda-python-alpha separately
Can I do this in TS and cdk? Or is this Sam specific?
This is a SAM specific feature, there are some libraries out there that try to fix this issue but I haven't seen anything good for complex scenarios yet. I'd normally stick to a simple test file where I import my app.py/index.js/index.ts file and call the handler with a test event. Pretty simple but so far I have had great results.