Slide 25
Slide 25 text
DEVELOP EFFECTIVE API
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
const fn = new lambda.Function(this, ”Lambda", {
runtime: lambda.Runtime.NODEJS_20_X,
code: lambda.Code.fromAsset("lambda"),
handler: "index.handler",
});
const api = new apigateway.SpecRestApi(this, "users-api", {
apiDefinition: apigateway.ApiDefinition.fromAsset("path-to-file.json"),
});
API Gateway を IaC 管理する要素(実装イメージ)
25
API 定義
AWS CloudFormation
または または
AWS SAM
paths:
"/users":
get:
description: get users
parameters:
- name: name
in: query
required: false
schema:
type: string
default: "World"
responses:
"200":
content:
"application/json":
schema:
$ref: "#/components/schemas/UsersResponse"
x-amazon-apigateway-integration:
type: "aws_proxy"
httpMethod: "POST"
uri: "arn:aws:apigateway:ap-northeast-1:lambda:path/2015-03-
31/functions//invocations"
ファイル参照
AWS CDK