LoginSignup
9
4

More than 5 years have passed since last update.

Serverless FrameworkでAPI Gatewayバイナリサポートを設定する

Last updated at Posted at 2018-02-03

API Gatewayでバイナリを扱いたい場合、バイナリサポートを有効にする設定が必要になります。
その設定をServerless Frameworkで定義しました。

ServerlessFrameworkのデフォルトではバイナリサポートの設定パラメータが用意されていないためプラグインを使用します。

調べたところ現時点では以下の2つのプラグインが見つかりました。

一つ目のserverless-apigw-binaryは試してみたときに、デプロイは成功していてもAPI Gatewayに反映されていないということがあったため、二つ目のserverless-plugin-custom-binaryを使うことにしました。

環境

$ npm -v
5.5.1

$ serverless -v
1.22.0

設定方法

プラグインのインストール

$ npm install --save-dev serverless-plugin-custom-binary

設定を追加

serverless.yml
plugins:
  - serverless-plugin-custom-binary

custom:
  apigatewayBinary:
    types:
      - multipart/form-data

デプロイ! :beer:

$ serverless deploy

デプロイ完了後、API Gatewayのコンソールで確認するとちゃんと設定されています。
スクリーンショット 2018-02-03 22.20.23.png

以上です。

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