AWS CLIでAPI Gatewayのget-exportでハマったのでメモ
ハマったこと
Swagger用のYAMLファイルをエクスポートしようとしたところ、以下のようなエラーが発生。
$ aws apigateway get-export \
--rest-api-id xxxxxxxxxx \
--stage-name prod \
--export-type swagger \
--accepts application/yaml swagger.yaml \
An error occurred () when calling the GetExport operation: Invalid stage identifier specified
原因
リージョンの設定が間違っていた。
テスト用に作ったため、~/.aws/configで設定していた東京リージョンとは異なるバージニアリージョンにAPI Gatewayを作成していた。
解決方法
~/.aws/configを直しても良いけど、今回のエクスポートに限ってリージョンを指定したいので、regionオプションを使用する。
$ aws apigateway get-export \
--rest-api-id xxxxxxxxxx \
--stage-name prod \
--export-type swagger \
--accepts application/yaml swagger.yaml \
--region us-east-1
{
"contentType": "application/octet-stream",
"contentDisposition": "attachment; filename=\"swagger_2016-10-21T10:49:03Z.yaml\""
}
OK。