Skip to content

Standalone Terraform config for an EC2-based GitHub Actions runner.

Notifications You must be signed in to change notification settings

hueper/runner-infra

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Actions Self-Hosted Runner

Standalone Terraform config for an EC2-based GitHub Actions runner. Solves the "no space left on device" error when building large Docker images (e.g. HuggingFace TGI base images) that exceed GitHub-hosted runner disk limits.

Apply when you need to build, destroy when you're done. Zero cost when destroyed.

Prerequisites

  • AWS CLI configured with appropriate credentials
  • Terraform >= 1.5
  • A fine-grained GitHub PAT scoped to the target repo with Administration: Read and write

Usage

terraform init

terraform apply \
  -var="github_repo=your-org/your-repo" \
  -var="github_pat=ghp_..."

# Runner appears in repo Settings > Actions > Runners within ~2-3 min.
# Trigger workflow_dispatch or push container changes to main.

terraform destroy \
  -var="github_repo=your-org/your-repo" \
  -var="github_pat=ghp_..."

Alternatively, supply variables via TF_VAR_github_pat env var or a .tfvars file (gitignored).

What It Provisions

Resource Details
EC2 instance t3.large, 200 GB gp3 root volume, Ubuntu 22.04 LTS
Security group All egress, zero ingress
IAM role SSM Session Manager access only — no ECR/AWS permissions (the workflow's OIDC role handles that)

Cost

~$2/day while running. $0 when destroyed.

Troubleshooting

If the runner doesn't appear in GitHub after apply, check the bootstrap log:

# Connect via SSM (command shown in terraform output)
aws ssm start-session --target <instance-id> --region eu-central-1

# Inside the instance
cat /var/log/runner-setup.log

Common issues: expired PAT, missing Administration scope, GitHub API rate limiting.

About

Standalone Terraform config for an EC2-based GitHub Actions runner.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published