Deployment error- A sibling ({DId}) of this resource already has a variable path part -- only one is allowed

ERROR:
Serverless: Packaging service…
Serverless: Uploading CloudFormation file to S3…
Serverless: Uploading function .zip files to S3…
Serverless: Updating Stack…
Serverless: Checking Stack update progress…
…Serverless: Deployment failed!

Serverless Error ---------------------------------------

 An error occurred while provisioning your stack: ApiGatewayResourceApiDevicesIdVar
 - A sibling ({DId}) of this resource already has
 a variable path part -- only one is allowed.

serverless.yml

  - http:
      method: DELETE
      path: api/devices/{id}
      cors: true
      integration: lambda

  - http:
      method: PATCH
      path: api/devices/{DId}
      cors: true
      integration: lambda

A quick test shows me that it will work if your path variable is the same i.e.

  - http:
      method: DELETE
      path: api/devices/{id}
      cors: true
      integration: lambda

  - http:
      method: PATCH
      path: api/devices/{id}
      cors: true
      integration: lambda

Can you just rename the variables? Remember that you can get the method used from the event.httpMethod property.

1 Like