AWS::ApiGatewayV2::Stage - AWS CloudFormation
AWS 文档中描述的 AWS 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅中国的 AWS 服务入门

AWS::ApiGatewayV2::Stage

AWS::ApiGatewayV2::Stage 资源更新 API 的阶段。

语法

要在 AWS CloudFormation 模板中声明此实体,请使用以下语法:

JSON

{ "Type" : "AWS::ApiGatewayV2::Stage", "Properties" : { "AccessLogSettings" : AccessLogSettings, "ApiId" : String, "AutoDeploy" : Boolean, "ClientCertificateId" : String, "DefaultRouteSettings" : RouteSettings, "DeploymentId" : String, "Description" : String, "RouteSettings" : Json, "StageName" : String, "StageVariables" : Json, "Tags" : Json } }

YAML

Type: AWS::ApiGatewayV2::Stage Properties: AccessLogSettings: AccessLogSettings ApiId: String AutoDeploy: Boolean ClientCertificateId: String DefaultRouteSettings: RouteSettings DeploymentId: String Description: String RouteSettings: Json StageName: String StageVariables: Json Tags: Json

属性

AccessLogSettings

该阶段中的日志记录访问的设置。

必需:否

类型AccessLogSettings

Update requires: No interruption

ApiId

API 标识符。

必需:是

类型:字符串

Update requires: Replacement

AutoDeploy

指定对 API 的更新是否自动触发新的部署。默认值是 false

必需:否

类型:布尔值

Update requires: No interruption

ClientCertificateId

Stage 的客户端证书的标识符。仅 WebSocket API 支持。

必需:否

类型:字符串

Update requires: No interruption

DefaultRouteSettings

阶段的默认路由设置。

必需:否

类型RouteSettings

Update requires: No interruption

DeploymentId

API 阶段的部署标识符。如果启用 autoDeploy,则无法更新。

必需:否

类型:字符串

Update requires: No interruption

Description

API 阶段的描述。

必需:否

类型:字符串

Update requires: No interruption

RouteSettings

阶段的路由设置。

必需:否

类型Json

Update requires: No interruption

StageName

阶段名称。阶段名称只能包含字母数字字符、连字符和下划线。最大长度为 128 个字符。

必需:是

类型:字符串

Update requires: Replacement

StageVariables

一个定义 Stage 的阶段变量的映射。变量名称可以包含字母数字和下划线字符,值必须匹配 [A-Za-z0-9-._~:/?#&=,]+。

必需:否

类型:Json

Update requires: No interruption

Tags

标签的集合。每个标签元素都与一个给定资源关联。

必需:否

类型:Json

Update requires: No interruption

返回值

Ref

在将此资源的逻辑 ID 传递给内部 Ref 函数时,Ref 返回阶段名称,例如 MyTestStage

For more information about using the Ref function, see Ref.

示例

阶段创建示例

以下示例创建一个名为 MyStagestage 资源,并将该资源与名为 MyDeployment 的现有 deployment 关联。

JSON

{ "MyStage": { "Type": "AWS::ApiGatewayV2::Stage", "Properties": { "StageName": "Prod", "Description": "Prod Stage", "DeploymentId": { "Ref": "MyDeployment" }, "ApiId": { "Ref": "CFNWebSocket" }, "DefaultRouteSettings": { "DetailedMetricsEnabled": true, "LoggingLevel": "INFO", "DataTraceEnabled": false, "ThrottlingBurstLimit": 10, "ThrottlingRateLimit": 10 }, "AccessLogSettings": { "DestinationArn": "arn:aws:logs:us-east-1:123456789:log-group:my-log-group", "Format": "{\"requestId\":\"$context.requestId\", \"ip\": \"$context.identity.sourceIp\", \"caller\":\"$context.identity.caller\", \"user\":\"$context.identity.user\",\"requestTime\":\"$context.requestTime\", \"eventType\":\"$context.eventType\",\"routeKey\":\"$context.routeKey\", \"status\":\"$context.status\",\"connectionId\":\"$context.connectionId\"}" } } } }

YAML

MyStage: Type: 'AWS::ApiGatewayV2::Stage' Properties: StageName: Prod Description: Prod Stage DeploymentId: !Ref MyDeployment ApiId: !Ref CFNWebSocket DefaultRouteSettings: DetailedMetricsEnabled: true LoggingLevel: INFO DataTraceEnabled: false ThrottlingBurstLimit: 10 ThrottlingRateLimit: 10 AccessLogSettings: DestinationArn: 'arn:aws:logs:us-east-1:123456789:log-group:my-log-group' Format: >- {"requestId":"$context.requestId", "ip": "$context.identity.sourceIp", "caller":"$context.identity.caller", "user":"$context.identity.user","requestTime":"$context.requestTime", "eventType":"$context.eventType","routeKey":"$context.routeKey", "status":"$context.status","connectionId":"$context.connectionId"}

另请参阅

  • Amazon API Gateway 版本 2 API 参考中的 CreateStage