I am using eclipse. I am creating rest api using aws lambda java with serverless framework. I am having issue to understand how to define query parameters in serverless yml file and access them in the code, i am not able access them.
This is how i have defined my lambda function with query parameters in serverless.yml file.
@bhaskyknl Indentation is important for YAML files. Can you please add ```yaml on the line before your serverless.yml and ``` on the line blow so that it maintains the correct formatting?
Hi @bhaskyknl,
I think your mistake is that your template is incorrect since you have double single quotes around toDate (it must be "toDate" : "$input.params('toDate')" instead of "toDate" : "$input.params(''toDate'')".
A few side notes:
protected Response handleRequest cannot be right. The visibility must be public!
Are you using the integration type integration: lambda on purpose? IMO lambda-proxy is much easier to use and gives you more flexibility. See Docs and Java Template
Since you are using Java, you might be interested in my Java framework JRestless allowing you to use JAX-RS on AWS-Lambda (for lambda-proxy, only).
Thanks for the update. I am able to access query params now.
I went through the doc using lambda-proxy. Can you please provide if you have any example for HTTP POST method using java for lambda-proxy?
I am using spring boot. After i deployed into aws lambda, i am getting aws gateway timeout error for 1st run, subsequent runs gives result within 30 mins. Is there a solution for this timeout issue?
to register binary media types (that’s not possible with serverless - you either need to do this manually or use some plugin)
to send a “Content-Type” request-header with one of the registered binary media types as value
decode the base64 encoded body, manually
regarding the timeout:
Spring Boot is a probably a little heavy… try to unregister everything that’s not really required (add some logging to see where you actually waste the time)
increase the timeout of your lambda function to 60s
Can you please provide an example how we mention lambda-proxy / aws-proxy / aws_proxy in serverless.yml and how we access the request/path variable using aws lambda java for PUT method?