简体   繁体   中英

Enable caching for url query parameters in aws api gateway with terraform

resource "aws_api_gateway_method" "MyDemoMethod" {
  rest_api_id   = aws_api_gateway_rest_api.example.id
  resource_id   = aws_api_gateway_resource.MyDemoResource.id
  http_method   = "ANY"
  authorization = "NONE"

  request_parameters = {
    "method.request.path.proxy" = true
    "method.request.querystring.tableid" = true
  }
}

With this script, I am trying to add a URL query parameter named tableid with caching enabled. But I can see no documentation referring to enabling the caching.

此代码的结果配置

To do so, this can be done using cache_key_parameters and cache_namespace as follows:

resource "aws_api_gateway_method" "MyDemoMethod" {
  rest_api_id   = aws_api_gateway_rest_api.example.id
  resource_id   = aws_api_gateway_resource.MyDemoResource.id
  http_method   = "ANY"
  authorization = "NONE"

  request_parameters = {
    "method.request.path.proxy" = true
    "method.request.querystring.tableid" = true
  }
  cache_key_parameters = ["method.request.querystring.tableid"]
  cache_namespace      = "mycache"
}

This was introduced in this Pull Request https://github.com/hashicorp/terraform-provider-aws/pull/893 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM