Ensure AWS API Gateway method settings enable caching

Error: AWS API Gateway method settings do not enable caching

Bridgecrew Policy ID: BC_AWS_GENERAL_163
Checkov Check ID: CKV_AWS_225
Severity: LOW

AWS API Gateway method settings do not enable caching


Enabling caching for API Gateway helps improve your API's performance by allowing clients to retrieve responses from a cache instead of making a request to the backend service. This can reduce the load on your backend service and improve the overall responsiveness of your API. It can reduce the cost of using your API by reducing the number of requests your backend service needs to handle. It can also improve the reliability of your API by allowing it to continue functioning even if the backend service is unavailable or experiencing problems.

Fix - Runtime

Fix - Buildtime


resource "aws_api_gateway_method_settings" "pass" {
  rest_api_id = aws_api_gateway_rest_api.fail.id
  stage_name  = aws_api_gateway_stage.fail.stage_name
  method_path = "path1/GET"

  settings {
    caching_enabled      = true
    metrics_enabled      = false
    logging_level        = "INFO"
    cache_data_encrypted = true
    data_trace_enabled   = false