Module: github-action-token-rotator
This module deploys a lambda function that runs as a GitHub Application and periodically gets a new GitHub Runner Registration Token from the GitHub API. This token is then stored in AWS Systems Manager Parameter Store.
Usage
module "github_action_token_rotator" {
source = "cloudposse/github-action-token-rotator/aws"
# Cloud Posse recommends pinning every module to a specific version
# version = "x.x.x"
parameter_store_token_path = "/github/runners/cloudposse/registrationToken"
parameter_store_private_key_path = "/github/runners/cloudposse/privateKey"
github_app_id = "111111"
github_app_installation_id = "22222222"
github_org = "cloudposse"
}
Quick Start
- Browse to https://github.com/organizations/\{YOUR_ORG\}/settings/apps and click the New GitHub App button
- Set the name to "GitHub Action Token Rotator"
- Set the Homepage URL to
https://github.com/cloudposse/lambda-github-action-token-rotator
- Uncheck the Active checkbox under the Webhook heading
- Select
Read and write
under Organization permissions -> Self-hosted runners - Click the Create GitHub App button at the bottom of the page
- Under the
Client secrets
section, click theGenerate a new client secret
button - Copy the Client secret to a safe place, it will be needed to install the app
- Under the
Private key
section, click theGenerate a private key
button - Download the private key to a safe place, it will be needed to install the app
- Convert the private key to a PEM file using the following command:
openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in {DOWNLOADED_FILE_NAME}.pem -out private-key-pkcs8.key
- Base64 encode the private key using the following command:
cat private-key-pkcs8.key | base64
- Copy the Base64 value to AWS SSM Parameter store at
/github/runners/${YOUR_GITHUB_ORG}/privateKey