gpt4 book ai didi

aws-cloudformation - CloudFormation - 如何引用无服务器使用计划?

转载 作者:行者123 更新时间:2023-12-03 07:22:41 25 4
gpt4 key购买 nike

问题:

我想将现有 API key 关联到新创建的“使用计划”,该计划是通过 AWS SAM 创建的,如下所示:

AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Resources:
ApiGatewayApi:
Type: AWS::Serverless::Api
Properties:
Name: MyAPI
OpenApiVersion: '2.0'
EndpointConfiguration:
Type: REGIONAL
StageName: prod
MethodSettings:
- ResourcePath: "/*"
HttpMethod: "*"
ThrottlingBurstLimit: 1
ThrottlingRateLimit: 1
Domain:
DomainName: api.mywebsite.com
CertificateArn: 'arn:aws:acm:eu-north-1:101010101010:certificate/88888888-4444-3333-2222-1111111111'
EndpointConfiguration: REGIONAL
Route53:
HostedZoneId: 'OMMITTD82737373'
BasePath:
- /
Auth:
UsagePlan:
CreateUsagePlan: PER_API
Description: Usage plan for this API
Quota:
Limit: 1000
Period: MONTH
Throttle:
BurstLimit: 1
RateLimit: 1
Tags:
- Key: Name
Value: MyUsagePlan
usagePlanKey:
Type: 'AWS::ApiGateway::UsagePlanKey'
Properties:
KeyId: 2672762828
KeyType: API_KEY
UsagePlanId: ????????????????????

是否可以在此处引用UsagePlanId?我尝试过: !RefUsagePlan 但没有成功......关于如何做到这一点有什么想法吗?

谢谢

最佳答案

据我所知,无法引用作为 Api 一部分创建的UsagePlan。

但是,您可以在 ApiGatewayApi 外部创建 UsagePlan 作为单独的资源,并将其与您的 ApiGatewayApi 关联。然后您可以轻松地在 UsagePlanKey 中引用它:

usagePlan:
Type: 'AWS::ApiGateway::UsagePlan'
Properties:
ApiStages:
- ApiId: !Ref ApiGatewayApi
Stage: prod
... (rest of the properties omitted)

usagePlanKey:
Type: 'AWS::ApiGateway::UsagePlanKey'
Properties:
KeyId: 2672762828
KeyType: API_KEY
UsagePlanId: !Ref usagePlan

关于aws-cloudformation - CloudFormation - 如何引用无服务器使用计划?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71440892/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com