- AWS CDK
- Deploy CDK stack using CloudShell
- Write Lambda app to send objects from S3 to Amazon Rekognition
- AWS account
- Choose a region that supports both AWS CloudShell and Amazon Rekognition. Open CloudShell and run:
sudo npm install -g aws-cdk
This will install CDK.
- Create a folder for the app and into it:
- Check if everything got created:
- Install the necessary packages:
npm install @aws-cdk/aws-s3 @aws-cdk/aws-iam @aws-cdk/aws-lambda @aws-cdk/aws-lambda-event-sources @aws-cdk/aws-dynamodb
- Update the cdk-app-stack.js in lib directory
And copy contents of the cdk-app-stack.js. If nano is not installed run
sudo yum install nano
This code will create constructs for S3 bucket, IAM Role, Lambda function, Lambda EventSource and DynamoDB.
- Leave the lib directory
Create a new directory for lambda function
Create index.py file
And paste the code from index.py
- Go one level up from lambda
then bootstrap the CDK applications:
This will create a CloudFormation stack and deploy a S3 bucket.
- Time to deploy the CDK defined resources, a CloudFormation stack will be created yet again and resources deployed.
When CdkAppStack in CloudFormation gets created it’s time for testing
- Upload some images to the newly created S3 bucket. That worked very nicly for me, after uploading some images of books, myself, my dog and group of friends having dinner those results were logged into DynamoDB table:
- Time for clean-up. Empty the S3 bucket and then in CloudBash run:
This will delete the CloudFormation stack and all the created resources.