
CodeBuild Meets GitHub Actions: A Serverless CI Workflow with Lambda
Serverless GitHub Actions? Yes! Learn how to use AWS Lambda/ CodeBuild for Github Actions workflow execution.
Published Feb 28, 2025
GitHub Actions provides a powerful CI/CD pipeline, but sometimes you need more control over the environment where your workflows run. AWS CodeBuild now supports Lambda-based self-hosted runners, allowing you to execute GitHub Actions workflows in a cost-efficient, on-demand AWS environment. This guide will walk you through setting up a self-hosted GitHub Actions runner using AWS CodeBuild's Lambda Runner environment.
Before getting started, ensure you have:
- An AWS account with permissions to create CodeBuild projects and Lambda functions
- A GitHub repository where you want to run the actions
- AWS CLI and GitHub CLI installed on your local machine
- An IAM role with necessary permissions for CodeBuild and Lambda execution
AWS CodeBuild will serve as our self-hosted GitHub Actions runner. Follow these steps:
- Open the AWS CodeBuild Console
- Click Create build project
- Project Name:
github-actions-runner
- Description:
Self-hosted GitHub Actions runner using AWS CodeBuild Lambda Runner

- Source: Select GitHub and connect to your repository

- Environment Image: Choose Managed Image
- Operating System: Amazon Linux 2
- Runtime: AWS Lambda
- Compute Type: Lambda Execution Environment
- Operating System System: Amazon Linux
- Runtime: Python
- Image & Version: Select the latest

- Choose New Service Role or select an existing role with permissions to execute CodeBuild, interact with GitHub, and access AWS Lambda.

- Attach the following policies if needed:
Click Create Build Project to finalize.
- Navigate to your GitHub repository
- Go to
Actions
tab and create a simple workflow. - To point the lambda self-hosted runner in place, update your
.github/workflows/main.yml
to use it: Please note theruns-on:
section here that you need to at to the workflow file.
Here is a full example of the workflow file.
Push changes to your repository, and the self-hosted runner in AWS CodeBuild will pick up the job and the lambda function will run your job.



Lambda compute is designed for speed, optimizing startup times for builds. However, it does have some limitations and does not support the following use cases:
- Reserved Capacity
- Caching Across Builds
- Restricting Runtime with Timeouts
- Tools Requiring Root-User Permissions
- Long-Running Builds (Lambda has a maximum timeout of 15 minutes)
Using AWS CodeBuild's Lambda Runner for GitHub Actions provides a scalable, cost-efficient alternative to traditional self-hosted runners. You only pay for execution time, and the Lambda-based environment ensures seamless scaling. Try this setup for your CI/CD workflows and enjoy the flexibility of AWS CodeBuild in your GitHub Actions pipelines!
Happy coding! 🚀