RequestParameters are not generated in Cloudformation

Hi,

I have the following entry in my serverless.yml

handler: src/handlers/users.getById
name: SKUsersGetById
events:
  - http:
      path: users/{id}
      method: get
      request:
        parameters:
          paths:
            id: true
      cors: true

It is not generating the path parameters in the Cloudformation file. So the AWS SDK is not generated correctly and no params are included in the generated sdk.

Am I doing something wrong or is this a bug in serverless?

Thanks for your help!

I’ve never tried to define the variables in the path and request properties at the same time (although I can see where you got the example from in the docs).

Try this definition:

handler: src/handlers/users.getById
name: SKUsersGetById
events:
  - http:
      path: users/{id}
      method: get
      cors: true

You’ll still see the id variable in the event.pathParameters object (i.e. event.pathParameters.id).

Hi,

tanks for your answer.
I have done this before.
The lambda functions are working this way but AWS then doesn’t have the path parameters in the generated SDK.

Sorry, I don’t understand what you mean by “generated SDK”.

If you go to /users/test do you see the value “test” in the event.pathParameters.id property? If so, then path parameter is being mapped to the variable defined.

I mean the API Gateway Client SDK Generation on AWS after you deploy your API.

Ah, now I understand.

I’ve never used that myself, so I’m not sure what’s missing to connect your serverless.yml function definition and the SDK definition.

Hi @gkTim, this might help:

resources:
  Resources:
    # The following are workarounds for the current inability to define querystrings while using
    # lambda-proxy integration.
    # Be sure to remove them once it's been fixed or a plugin has been developed!
    # And be sure to add any new querystring-needing functions here ...
    # you get their full name out of .serverless/cloudformation-template-update-stack.json:
    ApiGatewayMethodNotificationsDeviceidVarDelete:
      Properties:
        RequestParameters:
          method.request.path.deviceId: true
4 Likes

I’ve been looking ages for this. Thank you. (Sorry to revive this old post, but after 2 years this problem still exist)

Hey that’s awesome … that’s why I posted it. :slight_smile: Yeah I don’t know how many people are using the Generated SDK in this crowd.