amazon web services - Unable to turn off caching in API Gateway - Stack Overflow

I have this Terraform code:resource "aws_api_gateway_method" "proxy" {rest_api_id

I have this Terraform code:

resource "aws_api_gateway_method" "proxy" {
  rest_api_id   = aws_api_gateway_rest_api.dlx_mdm.id
  resource_id   = aws_api_gateway_resource.proxy.id
  http_method   = "ANY"
  authorization = "CUSTOM"
  authorizer_id = aws_api_gateway_authorizer.dlx_mdm_authorizer.id
    request_parameters = {
    "method.request.path.proxy" = true
  }
}

resource "aws_api_gateway_stage" "mdm_stage" {
  depends_on = [aws_cloudwatch_log_group.mdm_stage_log_group]

  stage_name    = "${local.stage_name}"
  rest_api_id   = aws_api_gateway_rest_api.dlx_mdm.id
  deployment_id = aws_api_gateway_deployment.mdm_deployment.id
}

resource "aws_api_gateway_method_settings" "method_settings" {
  rest_api_id = aws_api_gateway_rest_api.dlx_mdm.id
  stage_name  = aws_api_gateway_stage.mdm_stage.stage_name
  method_path = "*/*"

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

The resulting API Gateway method request looks like this:

This is the stage:

The issue is that I am unable to turn off the cache setting. Does anyone know how to control this? Publishing the API does not help.

I have this Terraform code:

resource "aws_api_gateway_method" "proxy" {
  rest_api_id   = aws_api_gateway_rest_api.dlx_mdm.id
  resource_id   = aws_api_gateway_resource.proxy.id
  http_method   = "ANY"
  authorization = "CUSTOM"
  authorizer_id = aws_api_gateway_authorizer.dlx_mdm_authorizer.id
    request_parameters = {
    "method.request.path.proxy" = true
  }
}

resource "aws_api_gateway_stage" "mdm_stage" {
  depends_on = [aws_cloudwatch_log_group.mdm_stage_log_group]

  stage_name    = "${local.stage_name}"
  rest_api_id   = aws_api_gateway_rest_api.dlx_mdm.id
  deployment_id = aws_api_gateway_deployment.mdm_deployment.id
}

resource "aws_api_gateway_method_settings" "method_settings" {
  rest_api_id = aws_api_gateway_rest_api.dlx_mdm.id
  stage_name  = aws_api_gateway_stage.mdm_stage.stage_name
  method_path = "*/*"

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

The resulting API Gateway method request looks like this:

This is the stage:

The issue is that I am unable to turn off the cache setting. Does anyone know how to control this? Publishing the API does not help.

Share Improve this question edited Nov 20, 2024 at 17:33 rboarman asked Nov 20, 2024 at 17:14 rboarmanrboarman 8,2149 gold badges60 silver badges91 bronze badges 4
  • Caching is configured on the stage, i.e, take a look at what the api_gateway_stage resource is doing. – Marko E Commented Nov 20, 2024 at 17:17
  • More detail added to the question. Thanks! – rboarman Commented Nov 20, 2024 at 17:34
  • Which provider version are you using? It's interesting because the documentation for the method cache settings says the following: Whether responses should be cached and returned for requests. A cache cluster must be enabled on the stage for responses to be cached.. – Marko E Commented Nov 20, 2024 at 21:35
  • Looks like 5.49 – rboarman Commented Nov 20, 2024 at 21:41
Add a comment  | 

1 Answer 1

Reset to default 0

You will need to enable API Gateway cluster cache, too, in aws_api_gateway_stage:

variable "api_gateway_cache_cluster_enabled" {
  default = "true"
}

variable "api_gateway_cache_cluster_size" {
  default = "0.5"
}


resource "aws_api_gateway_stage" "mdm_stage" {
  depends_on = [aws_cloudwatch_log_group.mdm_stage_log_group]

  cache_cluster_enabled = var.api_gateway_cache_cluster_enabled
  cache_cluster_size    = var.api_gateway_cache_cluster_size
  stage_name            = local.stage_name
  rest_api_id           = aws_api_gateway_rest_api.dlx_mdm.id
  deployment_id         = aws_api_gateway_deployment.mdm_deployment.id
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742341931a4425800.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信