0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Serverless Framework で、APIのパスの変数を変更した時にエラーが発生する問題を解決する

Posted at

Serverless Framework を使っていて、

既にデプロイしている API のパスを更新しようと、パスの変数を /users/query/{userId} から、/users/query/{teamId} に変更した時に、

Before

  users:
    handler: src/users.handler
    events:
      - httpApi:
          path: '/users/query/{userId}'
          method: GET
          authorizer:
            name: cognitoAuthorizer

After

  users:
    handler: src/users.handler
    events:
      - httpApi:
          path: '/users/query/{teamId}'
          method: GET
          authorizer:
            name: cognitoAuthorizer

下のようなエラーが発生した。同じメソッドで同じパスの時に変数名だけ変更しようとすると発生する。

 Serverless Error ----------------------------------------
 
  An error occurred: HttpApiRouteGetUsersQueryTeamidVar - The provided route key "GET /users/query/{teamId}" has a conflicting variable on the same hierarchical level as "GET /users/query/{userId}" (Service: AmazonApiGatewayV2; Status Code: 409; Error Code: ConflictException; Request ID: 8f2813aa-9e77-44e0-835a-171a7cf9d925; Proxy: null).

解決方法

この Issue にも書いてある通り、一旦該当の API をコメントアウトしてデプロイし、再度コメントアウト戻して削除するとデプロイできる。

Workaround for now:
Comment out the function from your serverless.yml, run a full deployment. This will delete the API gateway endpoint entirely, and then you can uncomment the function and run a deployment to deploy the new function with the new pathParam.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?