Slide 28
Slide 28 text
SERVERLESS DAYS TOKYO 2023 – REFACTORING SERVERLESS
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS Lambda
29
const handler = async (event) => {
const result = await rekognition.detectLabels({
Image: {
S3Object: {
Bucket: event.s3Bucket, Name: event.imageName }
},
});
};
AWS CDK
const detectObjectLambda = new lambda.Function(this, {…});
const detectObject = new tasks.LambdaInvoke(this, "Detect Object", {
lambdaFunction: detectObjectLambda,
payload: sfn.TaskInput.fromObject({
s3Bucket: imageBucket.bucketName,
imageName: this.IMAGE_TO_LABEL,
}),
outputPath: "$.Payload",
});
AWS CDK
const detectObject = new tasks.CallAwsService(this,””, {
service: "rekognition",
action: "detectLabels",
parameters: {
Image: {
S3Object: {
Bucket: imageBucket.bucketName,
Name: this.IMAGE_TO_LABEL,
},
},
},
…
});
AWS Lambda
不要
Original Refactored
AWS Step Functions Service Integration