FunctionCI — Continuous Integration for Serverless Functions
A Product Hunt Hackathon Build
I recently built FunctionCI as part of the Product Hunt Global Hackathon to solve a pain point I was having with AWS Lambdas. Specifically with Continuous Integration, deployments, and audit trails. Before I dive too deep into FunctionCI let me explain what Continuous Integration and Serverless Lambda functions are.
Continuous Integration is the process of merging, building, testing, and packaging your code on every source control commit.
This is important because it helps catch merge errors quickly.
It can also help in auditing. If your CI tool associates the source control commit ID with the build artifact, you can know what version of your code is running at any point in time.
Serverless Lambda Functions
AWS Lambda lets you run code without provisioning or managing servers. You pay only for the compute time you consume — there is no charge when your code is not running. With Lambda, you can run code for virtually any type of application or backend service — all with zero administration. Just upload your code and Lambda takes care of everything required to run and scale your code with high availability. You can set up your code to automatically trigger from other AWS services or call it directly from any web or mobile app.
FunctionCI is an Open Source application that you can run in your AWS account to manage your Lambda functions.
- FunctionCI builds, tests, packages, and versions your Lambda functions
- Builds are done by AWS CodeBuild and AWS CodePipeline
- Receive build notifications via Slack
- Deploy build artifacts to your Lambda functions via Slack
- View build history and deployment audit trails via Slack
FunctionCI is a Slack bot. All messages and interaction with FunctionCI is through your Slack team.
Once FunctionCI is up-and-running you can use the
/fn create project Slack command to create a new build project.
You will receive the following build notifications once your build version is ready.
You can then deploy the build artifact to your Lambda function uusing the
/fn deploy fn <fn-name> <project-name> <version> Slack command.
If you wish to see an audit trail of the latest deployments you can use the
/fn show fn <fn-name>Slack command. The great thing about this is that it also shows you who did the deployment and when.
You can also see a list of the latest builds via the
/fn show project <project>Slack command.
This is the basic usage of FunctionCI.
Here is the example project: https://github.com/rgfindl/functionci-demo
FunctionCI is also a serverless Lambda app. It includes the following AWS resources:
- API Gateway (Exposes an API for our Slack bot)
- Lambda (Slack bot API, SNS events, CloudWatch events, CodePipeline events)
- DynamoDB (Document storage)
- S3 (Build artifacts)
- CloudFormation (Builds a pipeline for each project)
- CodePipeline and CodeBuild (Performs builds)
For each project added to FunctionCI, FunctionCI creates a CodePipeline/CodeBuild stack via CloudFormation.
CodePipeline is triggered via Github. The first CodePipeline stage is CodeBuild. CodeBuild builds, tests, and packages your app. The final stage versions and archives the build artifacts.
Now that all your commits are versioned as build artifacts you’ll be ready to deploy to your Lambda.
If you wish to run FunctionCI the setup is very easy. Just follow these steps:
I hope FunctionCI can help you manage your Lambda functions properly. Please let me know what you think and if FunctionCI is helpful to you.