diff --git a/README.md b/README.md index 894e2d95b5..23888bce2f 100644 --- a/README.md +++ b/README.md @@ -159,7 +159,7 @@ resource "aws_iam_service_linked_role" "spot" { Next create a second terraform workspace and initiate the module, or adapt one of the [examples](./examples). -Note that `github_app.key_base64` needs to be the base64-encoded `.pem` file, i.e., the output of `base64 app.private-key.pem` (not directly the content of `app.private-key.pem`). +Note that `github_app.key_base64` needs to be a base64-encoded string of the `.pem` file i.e. the output of `base64 app.private-key.pem`. The decoded string can either be a multiline value or a single line value with new lines represented with literal `\n` characters. ```terraform module "github-runner" { diff --git a/modules/runners/lambdas/runners/src/scale-runners/gh-auth.ts b/modules/runners/lambdas/runners/src/scale-runners/gh-auth.ts index d60d4bebc1..e2da0fa5ce 100644 --- a/modules/runners/lambdas/runners/src/scale-runners/gh-auth.ts +++ b/modules/runners/lambdas/runners/src/scale-runners/gh-auth.ts @@ -51,7 +51,12 @@ async function createAuth(installationId: number | undefined, ghesApiUrl: string privateKey: Buffer.from( await getParameterValue(process.env.PARAMETER_GITHUB_APP_KEY_BASE64_NAME), 'base64', - ).toString(), + // replace literal \n characters with new lines to allow the key to be stored as a + // single line variable. This logic should match how the GitHub Terraform provider + // processes private keys to retain compatibility between the projects + ) + .toString() + .replace('/[\\n]/g', String.fromCharCode(10)), }; if (installationId) authOptions = { ...authOptions, installationId };