AWS noob here. This is a bit of a 'best practice development question' - but I'll try to be specific:
I know I can test Lambdas in node locally with a json file for input, but I'm not sure the best way to 'integration test' my web app, which will run in S3 and call the Lambdas in response to API Gateway endpoint calls.
It would be wonderful to use my actual API Gateway configuration files to enable me to call the same methods locally and execute my Lambdas locally. This article suggests that's not possible, yet as there's no local API gateway test environment: http://nickmchardy.com/blog/2015/09/my-thoughts-about-aws-api-gateway-working-with-aws-lambda
Perhaps this isn't clear, an example: if I have a users/ method in API Gateway, with GET and POST, which are connected to listUsers.js and createUser.js Lambdas respectively in AWS; in development I'd like to call: http://localhost:0000/users GET/POST and have it run the Lambdas and give the correct responses, so I can run my whole architecture locally.
Obviously calling a thing at a url isn't particularly complicated, so my question is more: what's the best practice for doing this considering I will have my (Cloudfront!? JAWS!?) configuration for how these things link together in AWS, can I make use of it for local testing at all?
Apologies if this is either not clear or very obvious!
Enables you to programmatically invoke your Lambda function locally by using the AWS CLI or SDKs. This command starts a local endpoint that emulates AWS Lambda. By default when you use this command, the AWS SAM CLI assumes that your current working directory is your project's root directory.
Oh. The answer is apparently 'Serverless' (formerly JAWS): https://github.com/serverless/serverless . Needed to keep Googling, apologies! Not sure whether to delete this question, now?! I guess it could be helpful for others? Especially as Serverless is new?
Our suite (Bespoken Tools) will allow you to do exactly this. This tutorial explains how: http://docs.bespoken.tools/en/latest/tutorials/tutorial_lambda_local/
The short summary is:
1) Install bespoken toolsnpm install bespoken-tools -g
2) Start a proxy with your Lambdabst proxy lamdba index.js
3) Take the URL that it prints out and use that in the API Gateway
Configure the API Gateway as an HTTP integration, and use the URL that is printed out when you start the proxy in Step 2.
Hope that helps! Once you have it setup, calls to your API Gateway will come directly to the Lambda running locally on your laptop.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With