A demo application for a technical guide showing how to deploy image classification applications on serverless environments following best practices using serverless computing.
Here’s what the CI/CD architecture looks like:
Here, an IAM user will use AWS CLI and git client to push our application code and some configuration files to a private CodeCommit repository. This new commit will trigger CodePipeline to create a new build for the Docker image from our Dockerfile and a specified build configuration using CodeBuild. Once the build is done and has succeeded, the Docker image will be pushed to a private registry in AWS ECR. You can now use the Docker image to create the Lambda function that’ll serve as the inference endpoint in production.
Here’s what the deployment architecture looks like:
The flow is stated on the image. You create a Lambda function inference endpoint with the Docker image you built from your ECR repository. At this point, you will test the function before deploying it. Once it’s deployed, you can now perform an end-to-end test by uploading a new image to the S3 bucket you created, this triggers the Lambda function that spins up your containerized application, runs a prediction, and returns the results to the DynamoDB table.
You can customize the code files to your needs. Ensure you replace the necessary tags and understand the structure of the functions. You can also instruct the Dockerfile
to download your own model instead.
To successfully along with this guide, here are some things you should know and have:
- A free tier AWS account or an active account with up to $3 in it. Following along with this guide should cost less than $3 as of the time of publication.
- Basic experience using AWS cloud and the command-line interface tool is set up and configured to work with your IDE. You can install the full AWS toolkit for VSCode here.
- Basic interaction with Docker CLI.
- An active IAM user is defined preferably (for security best practices). I’d advise you not to use the root user for this technical guide. You can provide access to the services listed below for the user:
-
iam_policy
contains the policy for the IAM user I created for this guide. Modify with your ownaccount ID
. -
s3_bucket
contains the sample public read policy for the bucket that will hold the inference images. -
test_images
contains images for testing the application once it is live.