LoginSignup
4
0

More than 5 years have passed since last update.

API Gateway: AWS CLIを使ってAPIのパスを変更する

Last updated at Posted at 2019-04-04

/v1/hoge/moge というパスを /v1/sage/moge のように移動したい場合

moge というリソースを移動させる(親をつけかえる)ことになる。

  1. API一覧を表示

    aws apigateway get-rest-apis
    

    APIのidを確認する。

  2. 指定APIのリソース一覧を表示

    aws apigateway get-resources --rest-api-id h4548bg9g9
    

    移動したいリソースのidと移動先(親)のリソースidを確認する。

  3. 移動

    aws apigateway update-resource \
      --rest-api-id h4548bg9g9 \
      --resource-id tvfwpe \
      --patch-operations op=replace,path=/parentId,value=6a65mm
    

(上記例では tvfwpe の親を 6a65mm に変更している)

/v1/hoge/v1/moge のようにリソース名を変更したい場合

前述の1, 2により <api-id><resource-id> を確認しておいて、下記でリネーム。

aws apigateway update-resource --rest-api-id <api-id> --resource-id <resource-id> --patch-operations op=replace,path=/pathPart,value=<new-name>

注意

変更したあとAPIのデプロイが必要。
また、この方法で変更するとLambdaの呼び出し許可をつけ直す必要があるので注意(マネジメントコンソールを使っていいなら、メソッドの編集のところで統合タイプ Lambda 関数 のラジオボタンをつけ直せば許可をつけ直せるはず)。

参考

https://stackoverflow.com/questions/36973234/move-resource-in-aws-api-gateway
https://medium.com/@onclouds/aws-api-gateway-rename-a-resource-name-77470ea57ce9

4
0
1

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
4
0