繁体   English   中英

AWS::Serverless::Api - 缓存集群设置缓存生存时间

[英]AWS::Serverless::Api - Cache Cluster set cache time to live

我已经使用 SAM 为 AWS::Serverless::Api 设置了一个 HTTP 代理。 尽管我能够设置 CacheClusterEnabled 和 CacheClusterSize。 我还没有找到设置缓存数据生存时间的属性。 我在哪里可以设置这个配置?

这是我的 templates.yml 文件:

Resources:


ProxyApi:
    Type: AWS::Serverless::Api
    Properties:
      CacheClusterEnabled: !FindInMap [EnvMap, !Ref Env, cacheClusterEnabled]
      CacheClusterSize: !FindInMap [EnvMap, !Ref Env, cacheClusterSize]
      Name: !Join [ '-', [!Ref Env, 'lead-generation-proxy'] ]
      StageName: !Ref Env
      DefinitionBody:
        Fn::Transform:
          Name: AWS::Include
          Parameters:
            Location: openapi/proxy.yml

这是创建的 API:

openapi: 3.0.1
info:
  version: 1.0.0
paths:
  "/{proxy+}":
    x-amazon-apigateway-any-method:
      parameters:
      - name: proxy
        in: path
        required: true
        schema:
          type: string
      responses: {}
      x-amazon-apigateway-integration:
        responses:
          default:
            statusCode: '200'
        requestParameters:
          integration.request.path.proxy: method.request.path.proxy
        uri: 
          Fn::FindInMap : [EnvMap, Ref: Env, proxyUrl]
        passthroughBehavior: when_no_match
        httpMethod: ANY
        type: http_proxy

任何有兴趣的人回答。 我发现我们可以使用https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigateway-stage-methodsetting.html#cfn-apigateway-stage-methodsetting-datatraceenabled配置这些属性。 这是我使用此配置的模板:

 ProxyApi:
    Type: AWS::Serverless::Api
    Properties:
      Name: !Join ["-", [!Ref Env, "lead-generation-proxy"]]
      StageName: !Ref Env
      TracingEnabled: !FindInMap [EnvMap, !Ref Env, tracingEnabled]
      CacheClusterEnabled: !FindInMap [EnvMap, !Ref Env, cacheClusterEnabled]
      CacheClusterSize: !FindInMap [EnvMap, !Ref Env, cacheClusterSize]
      MethodSettings:
        - HttpMethod: '*'
          ResourcePath: '/*'
          LoggingLevel: INFO
          CacheTtlInSeconds: 400
          CachingEnabled: !FindInMap [EnvMap, !Ref Env, cacheClusterEnabled]
          DataTraceEnabled: !FindInMap [EnvMap, !Ref Env, cacheClusterEnabled]
          MetricsEnabled: !FindInMap [EnvMap, !Ref Env, cacheClusterEnabled]
      DefinitionBody:
        Fn::Transform:
          Name: AWS::Include
          Parameters:
            Location: openapi/proxy.yml

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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