I have some python AWS lambdas which are deployed using serverless framework and I was able to retrieve the path variables using:
event.get("variable")
I am not sure what has changed but now I need to retrieve these path parameters using:
event.get("path").get("variable")
I am using lambda integration and my serverless configuration has not changed and looks like:
events:
- http:
operationId: delete
path: "${self:custom.prefix}/{id}"
method: delete
integration: lambda
request:
parameters:
paths:
id: true
I want to retrieve the id
variable using event.get("id")
, what do I need to do to remap the path parameters to be retrievable straight from the event?
Advertisement
Answer
I dont know if I was hallucinating but it doesnt seem as if what I was originally doing can ever work…
This is a solution although it is ugly, but posting here might help someone to understand what it is that I am trying to achieve, which is to get the path and request body into the event with nothing else:
request:
template:
application/json: >
{
"id": "$input.params('id')",
"name": "$util.escapeJavaScript($input.json('$.name')).replaceAll('\"','')"
}
parameters:
paths:
id: true
It is not pretty and if there is a more simplistic way to do this then I would appreciate knowing the answer!