This repository creates a Github Runner (self-hosted) on AWS for a single Github Repository.
Warning: this template creates AWS resources which incur costs.
This Cloudformation template sets up the following:
- A Single VPC, NAT Gateway, IG, Private/Public Subnet, VPC Endpoints to ensure private networking
- GithubRunner attached to your specified Github repository
-
Add this to your PRIVATE Github repository as a submodule:
git submodule add [email protected]:data-derp/github-runner-aws-cloudformation.git
- This module creates AWS Resources. If added to a public repository, anyone can fork and use the Github Runner and create AWS Resources.
-
Create a Github Personal Access Token with the Repo Scope. This will be used to generate a token to register a GithubRunner.
-
Set up your AWS CLI and authenticate to your AWS account and store those credentials in a named AWS profile (make sure it's active
export AWS_PROFILE=<your-profile>
) -
OPTIONAL: Switch your role (only if requred). For those expected to assume a role (within the same account) to perform AWS operations, there is a helper function:
./github-runner-aws-cloudformation/switch-role -b <starting-profile> -t <target-role>
This uses credentials in your
-b <starting-profile>
to switch into the-t <target-role>
. You can now use the target role's credentials by using the AWS_PROFILEdata-derp
export AWS_PROFILE=data-derp
-
Create the Stack.
./github-runner-aws-cloudformation/create-stack -p <your-project-name> -m <your-team-name> -r <aws-region> -u <your-github-username>
💡 the
your-project-name
andyour-team-name
must be globally unique as an AWS S3 bucket is created (this resource is globally unique) -
When prompted, enter your Personal Access Token (created in step 1)
Enter host password for user 'your-github-username': <the-personal-access-token>
-
View your Cloudformation Stacks in the AWS Console
-
When you're done, self-destruct your Github Runner:
./github-runner-aws-cloudformation/delete-stack -p <your-project-name> -m <your-team-name> -r <aws-region>
- Delete Stack (and SSM Param) script
- Handle different AWS regions