Ephemeral CI Runners on AWS

Federate GitHub Actions to AWS with OIDC (no static keys) and run ephemeral EC2 self-hosted runners with least-privilege IAM, private-subnet VPC design, and spot handling.

Overview

Why Ephemeral CI Runners on AWS

GitHub-hosted runners are convenient but give you no control over the network they run in, the IAM identity they carry, or the hardware they use. For a CI/CD stack that builds and tests against AWS resources (private artifact mirrors, ECR, GPU AMIs), you want runners that live inside your own VPC, assume a scoped IAM role, and disappear after a single job so no state leaks between builds.

The modern pattern has two independent halves. First, federate identity: GitHub Actions mints an OIDC token per job, and AWS trades it for temporary credentials via sts:AssumeRoleWithWebIdentity. This eliminates every long-lived AWS_ACCESS_KEY_ID secret from your repo. Second, run the job on an ephemeral EC2 instance: a webhook fires on workflow_job queued, a Lambda scales up an instance from a pre-baked AMI, the instance registers itself as a just-in-time (JIT) runner with --ephemeral, executes exactly one job, and terminates.

Key concepts

  • OIDC federation (AssumeRoleWithWebIdentity)
  • Trust policy sub and aud conditions
  • Ephemeral JIT runner
  • Scale-up / scale-down control flow
  • Custom runner AMI
  • Runner instance role vs deploy role
  • VPC endpoints / PrivateLink

Interview questions

  • How do you set up the GitHub-to-AWS OIDC trust so workflows get AWS credentials with no static keys?
  • Design the ephemeral EC2 runner lifecycle end to end. What launches an instance and what tears it down?
  • How do you lock down the IAM role attached to the runner EC2 instance?
  • Runners sit in private subnets and must reach an internal artifact mirror with no public IP. How do you wire egress?
  • You run on spot to cut cost. How do you survive an interruption mid-build?
  • How do you bake a runner AMI with the toolchain pre-installed and roll it out safely?

Sign up free to read the full topic

More Cloud topics

Start free on Cariara · Coding problems · System design studio