【发布时间】:2021-05-06 14:17:10
【问题描述】:
我有一个使用 terraform 创建 api 密钥的场景。现在,我们将在同一服务的第二个版本中转向无服务器。但是我们不想更新我们与其他团队共享的密钥。在无服务器中添加多个现有 api 的任何方式?
我尝试了这个解决方案,但它似乎不适用于多个键。 Using an existing API key with the Serverless Framework in AWS
【问题讨论】:
我有一个使用 terraform 创建 api 密钥的场景。现在,我们将在同一服务的第二个版本中转向无服务器。但是我们不想更新我们与其他团队共享的密钥。在无服务器中添加多个现有 api 的任何方式?
我尝试了这个解决方案,但它似乎不适用于多个键。 Using an existing API key with the Serverless Framework in AWS
【问题讨论】:
在您的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}
...
【讨论】: