Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i use multiple path parameters from serverless framework

I'm trying to deploy my serverless app. But have a problem like below.

An error occurred: ApiGatewayResourceServicesServiceidVar - A sibling ({id}) of this resource already has a variable path part -- only one is allowed  

And below is my code.

updateApplication:
    handler: handler.updateApplication
    memorySize: 3008
    description: Update application
    timeout: 30
    events:
      - http:
          path: services/{serviceId}/applications/{applicationId}
          method: post
          cors: true
          authorizer: authorize
          request:
            parameters:
              paths:
                serviceId: true
                applicationId: true

Any advice or suggestion would be appreciated. Thank you in advance.

like image 907
Hax0r Avatar asked Nov 18 '18 13:11

Hax0r


People also ask

How do I set environment variables for serverless?

To reference environment variables, use the ${env:SOME_VAR} syntax in your serverless. yml configuration file. It is valid to use the empty string in place of SOME_VAR . This looks like " ${env:} " and the result of declaring this in your serverless.

Which command is used to call the functions in serverless framework?

Invokes a deployed function. You can send event data, read logs and display other important information of the function invocation.

Does serverless framework create API gateway?

API Gateway is the fundamental part of serverless API, because it is responsible for the connection between a defined API and the function handling requests to that API. Thundra Foresight empowers developers to build successful CI pipelines by providing deep analytics and debugging capabilities.


1 Answers

The serverless framework seems to be complaining that you have defined the path parameters twice. Since you have declared it there directly below -http: you can remove the request: parameters: paths: block.

In other words, try this:

updateApplication:
    handler: handler.updateApplication
    memorySize: 3008
    description: Update application
    timeout: 30
    events:
      - http:
          path: services/{serviceId}/applications/{applicationId}
          method: post
          cors: true
          authorizer: authorize

Happy coding! 👍

like image 198
Jim Avatar answered Jan 04 '23 07:01

Jim