Coder Social home page Coder Social logo

pgar's Introduction

Pulumi Github Action Runner

Pulumi IaC for running Github Runners on AWS.

NOTE: This code needs to be bootstrapped from a developer machine with privileges once

Getting Started

Log into Pulumi service

pulumi login

Select the organization and stack

pulumi stack select maddalab/p-gar/ci-cd

Make sure you are invited to the organization

To set up Github Action runners

pulumi up

To destroy Github action runners

pulumi destroy

Implementation

  • Creates a VPC in 2 AZs
  • Each AZ has a private and public subnet
  • Each private subnet is configured with an instance of Github Runner for availability
  • Public subnets are unused
  • NAT gateway is created in private subnet to route traffic from Github Runner
  • Internet gateway is created in public subnet to route traffic to the internet
  • An autoscaling group is utilized to ensure that there are at least 2 runners at any time.
  • A lifecycle hook is associated with the instance in the auto scaling group
  • A lambda is invoked to deregister / remove the runner when the EC2 instance in the auto scaling group is terminated
  • User Data script is utilized to register EC2 instance as a runner.
  • A shell script is used to deregister EC2 instance. The script is invoked by the lambda.

Configurations

These are preconfigured for the stack maddalab/p-gar/ci-cd do this only if you are launching a new stack.

Configure pulumi with values for aws:region, GITHUB_ACCESS_TOKEN, GITHUB_ACTIONS_RUNNER_CONTEXT keyName.

GITHUB_ACCESS_TOKEN is PAT token save it to config as a secret

pulumi config set --secret GITHUB_ACCESS_TOKEN XXXX

GITHUB_ACTIONS_RUNNER_CONTEXT can be specified in two formats. One for user/repository for instance https://github.com/maddalab/pulumi-poetry-actions/ or alternatively for organizations for instance https://github.com/ooorganizationnn

Github runners for a single repository

pulumi config set GITHUB_ACTIONS_RUNNER_CONTEXT https://github.com/maddalab/pulumi-poetry-actions/

Github Runners for entire organization

pulumi config set GITHUB_ACTIONS_RUNNER_CONTEXT https://github.com/ooorganizationnnn

TODO

  • Currently this utilizes a PAT (personal account token associated with @maddalab's account) Replace it with a Organizational app token.

How to use

The intent of this repository is to both develop a pulumi solution for Github Runner and to dog food it for development as CI/CD. However by default the runners are shut down and not in use (it costs me money). To utilize the runners, follow the steps as below

# if you have multiple AWS profiles in your `credentials` file.
export AWS_PROFILE=<>
pulumi login
pulumi up

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.