LambdaをCDKで定義
10
AWS エバンジェリストシリーズ
AWSの基礎を学ぼう
#awsbasics
import { Stack, StackProps } from 'aws-cdk-lib';
import { Construct } from "constructs";
import * as lambda from "aws-cdk-lib/aws-lambda";
export class AwsCdkStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const handler = new lambda.Function(this, "StripeHandler", {
runtime: lambda.Runtime.NODEJS_14_X, // So we can use async in widget.js
code: lambda.Code.fromAsset("resources/functions"),
handler: "stripe.main",
environment: {
STRIPE_PRICE_LOOKUP_KEY: ‘lookup-key’,
STRIPE_SECRET_API_KEY: 'sk_xxx'
}
});
}}