Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rootfs/aws_ec2_self_host_runner
Create an AWS EC2 Github Action Self hosted Runner
https://github.com/rootfs/aws_ec2_self_host_runner
aws-ec2 aws-spot-instance ci-cd github-actions github-self-hosted-runner gitops-pipeline
Last synced: 12 days ago
JSON representation
Create an AWS EC2 Github Action Self hosted Runner
- Host: GitHub
- URL: https://github.com/rootfs/aws_ec2_self_host_runner
- Owner: rootfs
- License: apache-2.0
- Created: 2023-12-06T20:01:36.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2023-12-12T20:25:11.000Z (11 months ago)
- Last Synced: 2024-06-11T16:22:54.165Z (5 months ago)
- Topics: aws-ec2, aws-spot-instance, ci-cd, github-actions, github-self-hosted-runner, gitops-pipeline
- Language: Shell
- Homepage:
- Size: 28.3 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# aws_ec2_self_host_runner
Create an AWS EC2 Github Action Self hosted Runner
# Functions
- create an EC2 instance and register it as a Github self-hosted runner
- support spot instance. Fall back to on-demand if no spot instance found or bid price too low.
- auto clean runner and ec2 instance# Usage
Create Github secrets for AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION, AWS_SECURITY_GROUP_ID, MY_GITHUB_TOKEN (PAT, must have repo admin permission)
and use them in the workflow file:
```yaml
env:
AWS_REGION: ${{ secrets.AWS_REGION }}
GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SECURITY_GROUP_ID: ${{ secrets.AWS_SECURITY_GROUP_ID }}
GITHUB_REPO: ${{ github.repository }}
AMI_ID: ${{ github.event.inputs.ami_id }}
INSTANCE_TYPE: ${{ github.event.inputs.instance_type }
```# Instructions
# Define instance parameters
| Parameter | Description | Default Value |
|----------------------|-------------------------------------------------------------------------------------------------------|------------------------------------------|
| AMI_ID | The ID of the Amazon Machine Image (AMI) to use for the instance. | "ami-0e4d0bb9670ea8db0" (Ubuntu Server 20.04 LTS) |
| INSTANCE_TYPE | The type of the instance to launch. | "t2.micro" |
| SECURITY_GROUP_ID | The ID of the security group to associate with the instance. | Replace "YOUR_SECURITY_GROUP_ID" with the actual security group ID. |
| GITHUB_TOKEN | The GitHub token to authenticate with the GitHub API. Must have repo admin permission. | Replace "YOUR_TOKEN" with the actual GitHub token. |
| GITHUB_REPO | The GitHub repository in the format "owner/repo" to clone and use. | "sustainable-computing-io/kepler-model-server" |
| REGION | The AWS region to launch the spot instance. | "us-east-2" |
| DEBUG | Enable or disable debug mode. | "false" |
| KEY_NAME | The name of the key pair to use for the instance. | Replace "YOUR_KEY_NAME" with the actual key pair name. |
| GITHUB_OUTPUT | The name of the file to output the instance ID to. ***This is only for local test use. Don't set it in the workflow file.*** | "github_output.txt" |
| ROOT_VOLUME_SIZE | The size of the root volume in GB. | 200 |
| SPOT_INASTANCE_ONLY | If true, only create a spot instance. | "true" |
| CREATE_S3_BUCKET | If true, create a S3 bucket to store the model. | "false" |
| BUCKET_NAME | The name of the S3 bucket to store the model. | The bucket name is the same as the repo name with time date stamp. |