Reputation: 4861
I am trying to create an AWS SAM template which has a lambda which should be triggered by an API gateway.
The SAM template is only for the API gateway, and not for the API gateway. The API gateway will be created manually, and exists before the SAM template is deployed.
I understand that the way to do that is, under the resource I add :
Events:
APIName:
Type: Api
Properties:
Method : post
Path : /group/user
RestApiId:
Ref: MyApi
An example can be looked into here.
What I don't understand is, how exactly should I be using this for my use case.
Questions that I have:
/sendMesage
, then how would the template know which API gateway is to be referred to? I think it has something to do with the RestApiId, but I am not sure, because it's not a required field.Upvotes: 0
Views: 1045
Reputation: 4637
I'll get the questions one by one and hopefully I'll be of some help
API Name : What is to be put here? This is just an identifier for the API event you're creating. I normally use some form of description for the endpoint. Whatever you end up doing, try to have some convention or it will become hard to read (Http verb then action for instance, GetAllUsers)
How do I uniquely identify my API? :
It kinda feels like you actually have two different responsibilities and thus possibly two different path names here. If sendMessage can send a message to a group or to a user then you could have sendMessageToGroup
and sendMessageToUser
thus making them more explicit.
Can we not link up existing API gateway? : It would appear not judging by the docs but I might be wrong on that one.
Upvotes: 1