【发布时间】:2022-07-19 06:37:02
【问题描述】:
我对 AWS 无服务器和无服务器框架比较陌生。我创建了以下 API 路由并使用离线插件对其进行了测试,它按预期工作。但是,当我尝试使用 sls deploy 将其部署到我的 AWS 时,它会抛出以下错误。
Error:
CREATE_FAILED: ApiGatewayResourceNoteTimestampVar (AWS::ApiGateway::Resource)
Resource handler returned message: "A sibling ({note_id}) of this resource already has a variable path part -- only one is allowed (Service: ApiGateway, Status Code: 400, Request ID: c12acedd-d270-4988-bb01-427d058aa76c, Extended Request ID: null)" (RequestToken: 803cf4a6-5bc4-48c5-6648-2b0de46528f6, HandlerErrorCode: InvalidRequest)
我的 serverless.yml 看起来像这样
functions:
add-note:
handler: apis/add-note.handler
description: POST /note
events:
- http:
path: note
method: post
cors:
origins: "*"
headers: ${self:custom.allowedHeaders}
update-note:
handler: apis/update-note.handler
description: PATCH /note
events:
- http:
path: note
method: patch
cors:
origins: "*"
headers: ${self:custom.allowedHeaders}
delete-note:
handler: apis/delete-note.handler
description: DELETE /note/{timestamp}
events:
- http:
path: note/{timestamp}
method: delete
cors:
origins: "*"
headers: ${self:custom.allowedHeaders}
get-notes:
handler: apis/get-notes.handler
description: GET /note
events:
- http:
path: note
method: get
cors:
origins: "*"
headers: ${self:custom.allowedHeaders}
get-note:
handler: apis/get-note.handler
description: GET /note/{note_id}
events:
- http:
path: note/{note_id}
method: get
cors:
origins: "*"
headers: ${self:custom.allowedHeaders}
我不知道代码有什么问题,因为它在本地运行良好? 我很感激这里的帮助。
【问题讨论】:
标签: serverless serverless-framework aws-serverless