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

Terraform 管理の API Gateway Lambda 統合で 429 THROTTLED と出るとき

0
Posted at

事象

terraform plan / apply で API Gateway Lambda 統合を作ってた時、なんか動作確認で応答してくれない・エラーになった。原因をマネコンで探していると、下記のようにスロットリングの設定が 0 になっていた。

image.png

原因と対処

ということで明示しましょう:

resource "aws_apigatewayv2_stage" "default" {
  name        = "default"
  description = "Created by AWS Lambda"
  api_id      = aws_apigatewayv2_api.api.id
  auto_deploy = true

  access_log_settings {
    destination_arn = aws_cloudwatch_log_group.apigateway_log_group.arn
    format          = replace(file("${path.module}/api_gateway_log_format.json"), "\r\n", "")
  }

  default_route_settings {
    logging_level            = "ERROR"
    detailed_metrics_enabled = true
+   throttling_rate_limit    = 1
+   throttling_burst_limit   = 2
  }
}

おまけ:api_gateway_log_format.json は次のような json です。

api_gateway_log_format.json
{
  "requestId": "$context.requestId",
  "ip": "$context.identity.sourceIp",
  "caller": "$context.identity.caller",
  "user": "$context.identity.user",
  "requestTime": "$context.requestTime",
  "responseLatency": "$context.responseLatency",
  "protocol": "$context.protocol",
  "httpMethod": "$context.httpMethod",
  "resourcePath": "$context.resourcePath",
  "status": "$context.status",
  "error_message": "$context.error.message",
  "error_response_type": "$context.error.responseType",
  "integrationError": "$context.integration.error",
  "integrationErrorMessage": "$context.integrationErrorMessage",
  "integrationStatus": "$context.integration.integrationStatus",
  "integrationLatency": "$context.integration.latency"
}
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?