A Continuous Integration and Continuous Deployment setup for AWS Lambda functions with Docker images using GitHub Actions. Together with Semantic Releases and Conventional Commits, you can focus on writing your code. Automation takes care everything else.
You need to configure these environment variables as GitHub secrets:
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_REGION
CUSTOM_GITHUB_TOKEN
Everything runs with GitHub Actions; a full cycle includes three stages:
- Create n new Semantic Release
- Build and public an image for every GitHub Release
- Update service to use new image
Read more about Event-Driven Delivery.
on: push: branches: ["main"]
Every push on main
branch triggers the GitHub Action in version.yml
to create a new GitHub Release based on Conventional Commits.
on: release: types: ['created']
Every new GitHub Release triggers the GitHub Action in deployment.yml
to build the Docker image and upload the tagged image to the Amazon Elastic Container Registry. Afterwards, a new GitHub Deployment is created.
on: deployment_status
Using GitHub Deployments, the GitHub Action in release.yml
updates the AWS Lambda function to use the updated Docker image.
First, create a new repository using the Amazon Elastic Container Registry. The CloudFormation template in infrastructure.yml
includes all needed resources.
# Configure Amazon Elastic Container Registry
$ > AWS_REGION=eu-central-1 \
make deploy-infrastructure
Per default, GitHub configures an access token for every action run. When using the default token, an action cannot trigger any other actions. Therefore, a custom GitHub Token is needed for using the GitHub API.