I am currently using Serveless Framework to create a new application and was wanting to map the same lambda function to multiple HTTP methods (say, GET and POST) in my API gateway and I have gotten stuck on how to do this.
Here is what Serverless Framework generated in awsm.json for my default resource/action endpoint for the apiGateway configuration:
"apiGateway": {
"deploy": false,
"cloudFormation": {
"Type": "AWS",
"Path": "notify/event",
"Method": "POST",
"AuthorizationType": "none",
"ApiKeyRequired": false,
"RequestTemplates": {},
"RequestParameters": {},
"Responses": {
"400": {
"statusCode": "400"
},
"default": {
"statusCode": "200",
"responseParameters": {},
"responseModels": {},
"responseTemplates": {
"application/json": ""
}
}
}
}
}
So this allows my endpoint to accept a POST request, but how do I change this file to have this lambda also accept GET requests? I have tried the following:
"cloudFormation": {
...
"Method": [ "POST", "GET" ],
...
}
and
"cloudFormation": {
...
"Method": "POST,GET",
...
}
This is not currently supported (as of v1.4). It is a known issue that is being discussed (https://github.com/jaws-framework/JAWS/issues/295) and something similar is in the roadmap.
For now you will have to create a separate .awsm for each route & method
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