本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
ApiUsagePlan
为 API Gateway API 配置使用计划。有关使用计划的更多信息,请参阅《API Gateway 开发人员指南》中的使用 API 密钥创建和使用使用计划。
语法
要在您的 Amazon Serverless Application Model (Amazon SAM) 模板中声明此实体,请使用以下语法。
YAML
CreateUsagePlan:
String
Description:String
Quota:QuotaSettings
Tags:List
Throttle:ThrottleSettings
UsagePlanName:String
属性
-
CreateUsagePlan
-
确定如何配置此使用计划。有效值包括
PER_API
、SHARED
和NONE
。PER_API
会创建特定于此 API 的 AWS::ApiGateway::UsagePlan、AWS::ApiGateway::ApiKey 和 AWS::ApiGateway::UsagePlanKey 资源。这些资源的逻辑 ID 分别为
、<api-logical-id>
UsagePlan
和<api-logical-id>
ApiKey
。<api-logical-id>
UsagePlanKeySHARED
会创建 AWS::ApiGateway::UsagePlan、AWS::ApiGateway::ApiKey 和 AWS::ApiGateway::UsagePlanKey 资源,这些资源将在同一 Amazon SAM 模板中也具有CreateUsagePlan: SHARED
的任何 API 之间共享。这些资源的逻辑 ID 分别为ServerlessUsagePlan
、ServerlessApiKey
和ServerlessUsagePlanKey
。如果您使用此选项,我们建议您仅在一个 API 资源中为此使用计划添加其他配置,以避免定义冲突和状态不确定性。NONE
禁止创建使用计划或将使用计划与此 API 关联。在 Amazon SAM 模板的全局变量部分 中指定了SHARED
或PER_API
的情况下才需要这样做。有效值:
PER_API
、SHARED
和NONE
类型:字符串
必需:是
Amazon CloudFormation 兼容性:此属性为 Amazon SAM 独有,没有 Amazon CloudFormation 等效属性。
-
Description
-
使用计划的描述。
类型:字符串
必需:否
Amazon CloudFormation 兼容性:此属性直接传递给
AWS::ApiGateway::UsagePlan
资源的Description
属性。 -
Quota
-
配置用户可在指定时间间隔内发出的请求的数量。
必需:否
Amazon CloudFormation 兼容性:此属性直接传递给
AWS::ApiGateway::UsagePlan
资源的Quota
属性。 -
与使用计划关联的任意标签(键值对)的数组。
此属性使用CloudFormation 标签类型。
类型:列表
必需:否
Amazon CloudFormation 兼容性:此属性直接传递给
AWS::ApiGateway::UsagePlan
资源的Tags
属性。 -
Throttle
-
配置整体请求速率(每秒平均请求数)和突发容量。
必需:否
Amazon CloudFormation 兼容性:此属性直接传递给
AWS::ApiGateway::UsagePlan
资源的Throttle
属性。 -
UsagePlanName
-
使用计划的名称。
类型:字符串
必需:否
Amazon CloudFormation 兼容性:此属性直接传递给
AWS::ApiGateway::UsagePlan
资源的UsagePlanName
属性。
示例
UsagePlan
以下是使用计划示例。
YAML
Auth: UsagePlan: CreateUsagePlan: PER_API Description: Usage plan for this API Quota: Limit: 500 Period: MONTH Throttle: BurstLimit: 100 RateLimit: 50 Tags: - Key: TagName Value: TagValue