OpenAPI 定義では、次の AWS 変数を使用できます。API Gateway は、API のインポート時に変数を解決します。変数を指定するには、${
を使用します。次の表は、使用可能な AWS 変数について説明しています。variable-name
}
変数名 | 説明 |
---|---|
AWS::AccountId |
API をインポートする AWS アカウント ID。例: 123456789012。 |
AWS::Partition |
API のインポート先の AWS パーティション。標準の AWS リージョンの場合、パーティションは aws です。 |
AWS::Region |
API のインポート先の AWS リージョン。例: us-east-2 。 |
AWS 変数の例
次の例では、AWS 変数を使用して統合用の AWS Lambda 関数を指定します。
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