簡體   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