Slide 13
Slide 13 text
型を定義しながらAWSが開発できる
export interface LambdaApiProps {
environment?: { [key: string]: string }
lambdaPath: string
}
export class LambdaApi extends cdk.Construct {
public readonly handler: lambda.Function
public readonly api: apigateway.LambdaRestApi
constructor(scope: cdk.Construct, id: string, { environment, lambdaPath }: LambdaApiProps) {
super(scope, id)
this.handler = new lambda.Function(this, `${id}Handler`, {
runtime: lambda.Runtime.NODEJS_12_X,
code: lambda.Code.asset(lambdaPath),
handler: 'index.handler',
environment
})
this.api = new apigateway.LambdaRestApi(this, `${id}Endpoint`, {
handler: this.handler
})
}
}