【问题标题】:Using an existing API keys(multiple keys) with the Serverless Framework in AWS将现有 API 密钥(多个密钥)与 AWS 中的无服务器框架一起使用
【发布时间】:2021-05-06 14:17:10
【问题描述】:

我有一个使用 terraform 创建 api 密钥的场景。现在,我们将在同一服务的第二个版本中转向无服务器。但是我们不想更新我们与其他团队共享的密钥。在无服务器中添加多个现有 api 的任何方式?

我尝试了这个解决方案,但它似乎不适用于多个键。 Using an existing API key with the Serverless Framework in AWS

【问题讨论】:

    标签: aws-api-gateway api-key


    【解决方案1】:

    在您的serverless.yml 中定义多个AWS::ApiGateway::ApiKey 资源。只需确保这些值与您现有的键匹配即可。

    resources:
      Resources:
        ExistingKey1:
          Type: AWS::ApiGateway::ApiKey
          Properties: 
            Enabled: true
            StageKeys: 
              - RestApiId:
                  Ref: ApiGatewayRestApi
                StageName: ${sls:stage}
            Value: myexistingapikeythatisatleasttwentycharacterslong
          DependsOn: ApiGatewayDeployment${sls:instanceId}
    ...
    

    【讨论】:

      猜你喜欢
      • 2017-03-28
      • 2018-07-29
      • 1970-01-01
      • 2019-07-04
      • 1970-01-01
      • 1970-01-01
      • 2013-07-16
      • 2012-10-19
      • 2021-01-06
      相关资源
      最近更新 更多