diff --git a/README.md b/README.md index 532f0d6d2f..c85695f8ea 100644 --- a/README.md +++ b/README.md @@ -157,7 +157,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 297edd0b27..dadb1dcbd4 100644 --- a/modules/runners/lambdas/runners/src/scale-runners/gh-auth.ts +++ b/modules/runners/lambdas/runners/src/scale-runners/gh-auth.ts @@ -48,7 +48,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 };