1
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 3 years have passed since last update.

AWS API Gateway 雑記

Last updated at Posted at 2020-07-01

AWS API Gateway(REST API)を触った際の雑記。

構造

api_gateway_model_v2.png

要素を一部抜粋した概要図。詳細な概要図はAWS-Blackbelt_APIGateway(API Gateway の概要図)にある。

統合

各種、統合は開発ガイドを参照する。プライベート統合、かつPROXYタイプは、 VPC_PROXY として扱う。(terraformで表現するときに利用した)

ステージ

ステージ間で動的な値を扱いたい場合。ResourcesはAPIで1つなので、ステージ毎に作成することはできない。Methodの中でステージ変数を参照することで実現できる。例えば、統合リクエストのURIに設定するドメインをステージ変数に切り替えることなど。

参考:REST API デプロイのステージ変数のセットアップ

スロットリング

AWS-Blackbelt_APIGateway(スロットリング - トークンバケット)が分かりやすい。ステージ毎に設定可能。

ログ

実行ログとアクセスログの2つがある。

  • 実行ログ:統合リクエストの実行ログ、即ちバックエンドへのリクエストログ。タイムアウトや疎通に失敗する際に出力される。
  • アクセスログ:APIGatewayへのアクセスログ。IPやアクセスされたパス、呼び出し元に返却するHTTPステータスコードなどが設定できる。

参考:API Gateway での REST API の CloudWatch ログ記録の設定

所感

  • AWS-Blackbelt_APIGatewayを見た上で開発者ガイドを見た方が全体像を把握しやすく、ユースケースに合う設定が見つかりやすいと思う
  • 当たり前だが、概要(構成部の依存関係など)を理解しないと詰まる

参考

1
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
1
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?