用于 OpenAPI 导入的 Amazon 变量 - Amazon API Gateway
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

用于 OpenAPI 导入的 Amazon 变量

您可以在 OpenAPI 定义中使用以下 Amazon 变量。API Gateway 在导入 API 时解析变量。要指定变量,请使用 ${variable-name}

Amazon 变量
变量名称 说明
AWS::AccountId 导入 API 的 Amazon 账户 ID(例如,123456789012)。
AWS::Partition 在其中导入 API 的 Amazon 分区。对于标准 Amazon 区域,分区是 aws
AWS::Region 在其中导入 API 的 Amazon 区域,例如 us-east-2

Amazon 变量示例

以下示例使用 Amazon 变量为集成指定 Amazon Lambda 函数。

OpenAPI 3.0
openapi: "3.0.1" info: title: "tasks-api" version: "v1.0" paths: /: get: summary: List tasks description: Returns a list of tasks responses: 200: description: "OK" content: application/json: schema: type: array items: $ref: "#/components/schemas/Task" 500: description: "Internal Server Error" content: {} x-amazon-apigateway-integration: uri: arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/arn:${AWS::Partition}:lambda:${AWS::Region}:${AWS::AccountId}:function:LambdaFunctionName/invocations responses: default: statusCode: "200" passthroughBehavior: "when_no_match" httpMethod: "POST" contentHandling: "CONVERT_TO_TEXT" type: "aws_proxy" components: schemas: Task: type: object properties: id: type: integer name: type: string description: type: string