Slide 20
Slide 20 text
@aws-cdk/aws-
lambda-nodejs
͕ศར
new lambda.NodejsFunction(this, 'my-handler', {
bundling: {
commandHooks: {
beforeBundling(inputDir: string, outputDir: string): string[] {
return [
`echo hello > ${inputDir}/a.txt`,
];
},
afterBundling(inputDir: string, outputDir: string): string[] {
return [`cp ${inputDir}/b.txt ${outputDir}/txt`];
},
beforeInstall() {
return [];
}, },
minify: true, // minify code, defaults to false
sourceMap: true, // include source map, defaults to false
target: 'es2020',
loader: { // Use the 'dataurl' loader for '.png' files
'.png': 'dataurl',
},
define: { // Replace strings during build time
'process.env.API_KEY': JSON.stringify('xxx-xxxx-xxx'),
},
logLevel: lambda.LogLevel.SILENT, // defaults to LogLevel.WARNING
keepNames: true, // defaults to false
tsconfig: 'custom-tsconfig.json', // use custom-tsconfig.json
instead of default,
…
• TypeScriptͷίʔυΛ
esbuildͰίϯύΠϧͯ͠
AWS LambdaʹσϓϩΠ
• Lambdaͷ࣮ͱߏ
྆ํ·ͱΊͯTSͰཧͰ͖Δ