Ensure API gateway caching is enabled

Error: API gateway caching is disabled

Bridgecrew Policy ID: BC_AWS_GENERAL_128
Checkov Check ID: CKV_AWS_120
Severity: LOW

API gateway caching is disabled


This checks that all methods in an Amazon API Gateway stage to ensure that they have caching enabled.
As AWS puts it "With caching, you can reduce the number of calls made to your endpoint and also improve the latency of requests to your API" and so if you need to minimise those, this will help.
See the AWS docs for more information: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-caching.html

Fix - Runtime

To configure API caching for a given stage:

  • Go to the API Gateway console.

  • Choose the API.

  • Choose Stages.

  • In the Stages list for the API, choose the stage.

  • Choose the Settings tab.

  • Choose Enable API cache.

Wait for the cache creation to complete.

Fix - Buildtime


  • Resource: AWS::ApiGateway::Stage
  • Argument: CacheClusterEnabled
AWSTemplateFormatVersion: "2010-09-09"
    Type: AWS::ApiGateway::Stage
      StageName: test
      Description: test
      RestApiId: test
      DeploymentId: test
+      CacheClusterEnabled: true

Fix - Buildtime


  • Resource: aws_api_gateway_stage
  • Argument: cache_cluster_enabled
resource "aws_api_gateway_stage" "examplea" {
  deployment_id = aws_api_gateway_deployment.stage_api.id
  rest_api_id   = aws_api_gateway_rest_api.api.id
  stage_name    = "example"
  cache_cluster_enabled = true