Self host GitHub Actions AWS CodeBuild
Start-up

Self host GitHub Actions AWS CodeBuild

Safe costs or automate processes on AWS

Tobias  Vonesch
Tobias Vonesch
Technical Sales Engineer & AWS Consultant

In DevOps environments we strive for a high level of automation. Automation reduces human errors and introduces standardization across teams and employees. Typical automation tasks can be linting and compiling code or packaging and deploying software.

Introduction

We automate such tasks by using so-called runners. These programs listen to an orchestrator which is typically either provided by your Git platform (GitHub, GitLab or Bitbucket) or a third party tool like Jenkins or Travis CI.

As a popular Git provider, GitHub-Actions are among the most popular automation runners. You can either use the runners GitHub is providing you or you can host your own runners.

AWS has announced that CodeBuild pipelines now support organization enterprise level self hosted runners for GitHub-Actions.

Using GitHub's provided runners

GitHub is quite generous to hobbyists and open-source projects. There is a free tier that allows anybody to run up to 2000 minutes of build tasks on GitHub managed runners — but only for public repositories.

Here is a short overview of the different pricing models:

Tier
Storage
Runner Minutes
Pricing
GitHub Free500 MB2'000$ 0 / user / month
GitHub Team2 GB3'000$ 4 / user / month
GitHub Enterprise Cloud50 GB50'000$ 21 / user / month

Every runner using the Windows operating system uses double the amount of minutes from your quota. With macOS even 10x.

Operating System
Minute Multiplier
Linux1x
Windows2x
macOS10x

AWS CodeBuild

AWS has its own managed solution for runners called AWS CodeBuild. CodeBuild is part of the Code series of services like CodePipeline, CodeDeploy, or CodeArtifact. It also integrates with S3 and ECR.

CodeBuild offers a wide variety of options for software construction. You can choose between different instance types, control where instances run (which region), and even place them in a VPC for easy network connectivity.

AWS Connector for GitHub

The easiest way to connect your AWS account to your GitHub account is by installing the AWS Connector for GitHub. In the AWS console, under "connections," you can install the Connector as an "application" on your GitHub account.

Pricing

Using Linux instances:

CPU

GitHub

AWS (us-east-1)

AWS (eu-central-1)

AWS (eu-central-2)
CPU

GitHub

AWS (us-east-1)

AWS (eu-central-1)

AWS (eu-central-2)
2 vCPU (arm)$ 0.005$ 0.0034$ 0.00385N/A
2 vCPU (x86)$ 0.008$ 0.005$ 0.005$ 0.005
4 vCPU (arm)$ 0.01$ 0.007$ 0.008N/A
4 vCPU (x86)$ 0.016$ 0.01$ 0.01$ 0.01
8 vCPU (arm)$ 0.02$ 0.015$ 0.0175N/A
8 vCPU (x86)$ 0.032$ 0.02$ 0.02$ 0.02
Windows Runners:
CPU

GitHub

AWS (us-east-1)

AWS (eu-central-1)

AWS (eu-central-2)
2 vCPU (x86)$ 0.016N/AN/AN/A
4 vCPU (x86)$ 0.032$ 0.018$ 0.019N/A
8 vCPU (x86)$ 0.064$ 0.02$ 0.038N/A

(us-east-1 = North Virginia, eu-central-1 = Frankfurt, eu-central-2 = Zurich)

The available AWS runners are significantly cheaper than the GitHub ones. Using reserved capacity can lower the price per minute by half or more.

Automate and Deploy

Besides the price there is another good argument for using CodeBuild with GitHub. You might spare yourself the need of bridging authentication to your infrastructure.

In case you are using Terraform or OpenTofu, you can plan changes, store those plans as artefacts in S3 and apply them later on. Another possibility is to execute system tests by placing the runner instance into the VPC where the testing Database runs. Deployment becomes a breeze since the build artifacts and containers are already within AWS.

Conclusion

CodeBuild self hosted runners offer an easy, secure and affordable way of combining leading Git platforms and AWS computation power. Besides being more affordable than GitHub hosted runners, CodeBuild integrates with your AWS environment and brings your software construction, testing and deploy tasks closer to your infrastructure.

Sources

blog.aboutAuthor

Tobias  Vonesch
Tobias Vonesch
Technical Sales Engineer & AWS Consultant

He co-hosts Containers and AWS meetup series and is active in the builder community.

blog.linkedInProfile