2

I'm creating an aws lambda function using VS Code aws plugin, the language is nodeJS.

I need to pass a dynamic id in the request preferably as part of the path.

In nodeJS express I would do it something like this

/api/route/:id

However when I try to do this in my lambda function's template.yaml like this

Events:
    HelloWorld:
      Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
      Properties:
      //***** this line
        Path: /api/route/:id
        Method: get

It does'n work

Any help would be appreciated

P.S. I'm able to pass it as a query param like so

https://awslambdafunction.com/api/route/?id=1234

It does work but I would really like to have it as part of the path itself like this

https://awslambdafunction.com/api/route/1234    

1 Answer 1

5

Shmili,

I'm not sure if it'll work with AWS VS Code plugin. But I did it like this using Serverless Framework:

functions:
  updateBook:
    handler: handler.updateBook
    events:
      - http:
          path: /book/{id}
          method: put
          private: true

It may put you on a right direction.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.