Open gavetisyanca opened 4 years ago
You can add multiple events to a function, in this example, sqs and schedule, you just add what you need.
Thanks for your quick response , Much appreciated really @estebansolo I just don't know how to integrate this code with what you just posted : ) Can we NOT use SQS ? This code is from https://github.com/serverless/examples/tree/master/aws-node-rest-api-with-dynamodb
functions: create: handler: todos/create.create events:
http: path: todos method: post cors: true
list: handler: todos/list.list events:
http: path: todos method: get cors: true
get: handler: todos/get.get events:
http: path: todos/{id} method: get cors: true
update: handler: todos/update.update events:
http: path: todos/{id} method: put cors: true
delete: handler: todos/delete.delete events:
In my case I haven't used serverless framework, however as I saw it could be as follows, just organize which file and handler is going to receive the requests and try to execute it.
https://www.serverless.com/framework/docs/providers/aws/events/schedule/
Here they use multiple events, although they are schedule type I would think it works the same way for http.
functions:
function_name:
handler: js_file.handler
events:
- http:
path: todos
method: post
cors: true
- http:
path: todos
method: get
cors: true
- http:
path: todos/{id}
method: get
cors: true
- http:
path: todos/{id}
method: put
cors: true
- http:
path: todos/{id}
method: delete
cors: true
@estebansolo Bunch of thanks for your time and help
I have a different question. How do I have 1 lambda function with different events (different http methods) I don't want to create several lambda functions for each method its not interesting and not efficient. I want to be able trigger that function with either with boolean logic inside the actual script or even better edit this serverless.yml file so I can do that from yaml rather than inside the script Please help me, will much appreciate that
Originally posted by @gavetisyanca in https://github.com/aws-samples/aws-serverless-samfarm/issues/5#issuecomment-671002101