LoginSignup
0
0

AWS API Gateway

Posted at

制限

- 29秒のタイムアウト(lambdaが15分でもこっちがダメになるケースに注意)
- 最大10MBペイロードサイズ
    - S3の前にAPI GWをおいてアップロードしようとする場合に注意。10MB以上をアップロードしたいならlambdaを挟んでpre-signed URLを返すようにするとよい

Stage

- Stage単位でデプロイする。クライアントはstageに対してリクエストを行う
- ロールバック可能

Endpoint

- Edge-Optimized(default):
    - CloudFrontを経由してリクエスト
    - API GWは1つのリージョンのみに存在
- Regional
    - cache(backendへの呼び出しを減らす)やより細かく配信したい場合用。
    - クライアントから直接REST APIにリクエストが届く。そのためEdgeよりレイテンシが低くなることもあるようだ。
    - CloudFrontと組み合わせも可能
- Private(VPC)
    - VPC、PrivateLinkを経由したアクセス用

cache

- デフォルト300秒(5分)。min:0,max:3600s(60m)
- stageごとに定義
- メソッドごとにキャッシュをオーバーライド可能(特定のリクエストをキャッシュさせないとかも可能)
- クライアントもcache-control:max-age=0 というヘッダでキャッシュを無効にできる(IAMで設定が必要)
- キャッシュは暗号化でき、0.5GB~237GBで設定可能

Error

- 4**系エラー(Client error)
    - 400: bad request
    - 403: access denied, WAF filterd
    - 429: Quota exceeded,Throttle
- 5**系エラー(Server error)
    - 502: bad gateway exception(lambda関数の問題がある)
    - 503: Service Unavailable Exception(backendとのアクセス問題)
    - 504: Integration Failure(API Gatewayのタイムアウト29秒など)

Security

- SSL使用可能
    - R53でCNAMEを定義できる
- Resource Policy(S3バケットポリシーと同じように使える)

認証

- IAM based access
- Lambda Authorizer
- Cognito User Pools

loging

- CW logs
- CW metrics
- X-Ray
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