Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure github app pem file from environment variable #1636

Open
dtelaroli opened this issue Jun 16, 2021 · 8 comments
Open

Configure github app pem file from environment variable #1636

dtelaroli opened this issue Jun 16, 2021 · 8 comments
Labels
feature New functionality/enhancement Stale

Comments

@dtelaroli
Copy link

I'm using atlantis in ECS fargate directly from atlantis docker hub, now I need set the github app pem file, but I want use environment variable to easy configuration from AWS SSM Parameter Store.

Is it possible without customize the image?
If no, would be nice to have.

@dtelaroli
Copy link
Author

As workaround I've created an image which replace the entrypoint file to execute a command before startup.
I use a new env variable with the pem content, named ATLANTIS_GH_KEY_VALUE, and on startup the script creates the key file.

ARG ATLANTIS_VERSION

FROM runatlantis/atlantis:$ATLANTIS_VERSION

RUN sed '/^exec.*/i echo "$ATLANTIS_GH_KEY_VALUE" > $ATLANTIS_GH_APP_KEY_FILE' /usr/local/bin/docker-entrypoint.sh

@nishkrishnan
Copy link
Contributor

The api we use specifically requires a file. https://github.com/runatlantis/atlantis/blob/master/server/events/vcs/github_credentials.go#L131 but looks like there's another api available from that library that uses the bytes directly so probably something that can be added.

@vitaly-dt
Copy link

vitaly-dt commented Jun 8, 2023

Hi, I am trying to use the environment variable ATLANTIS_GH_APP_KEY
I am getting the following error:

Error: initializing server: error initializing github authentication transport: could not parse private key: invalid key: Key must be a PEM encoded PKCS1 or PKCS8 key

How is it configured:
I tried the following methods:

  1. One line string: with & without quotes, with & without \n
  2. As binary - creating the secret as binary from the aws cli

The string looks ok to the naked eye, but it's not parsed correctly.
Can someone assist, please?

@barth12
Copy link

barth12 commented Jan 26, 2024

Did you figure it out @vitaly-dt ?

@vitaly-dt
Copy link

Did you figure it out @vitaly-dt ?

@barth12 No, I had to mount the key and reference its path for Atlantis.

@wwahlstedt
Copy link

wwahlstedt commented Mar 7, 2024

I think this is still broken. It must be a bug.

@bilenkis
Copy link

Also face the same issue. No matter how I format the PEM key ENV the error is still the same:

Error: initializing server: error initializing github authentication transport: could not parse private key: invalid key: Key must be a PEM encoded PKCS1 or PKCS8 key

@artworkad
Copy link

In a containerized environment you can spin up a second side-car container that mounts the same volume as atlantis and writes the key to a pem file. When using https://github.com/terraform-aws-modules/terraform-aws-atlantis on ECS Fargate it would look like:

config = {
  ...
  image = "bash"
  enable_execute_command = true
  command = ["echo \"$ATLANTIS_GH_APP_KEY\" > /home/atlantis/github_app_key.pem"]
  entrypoint = ["sh", "-c"]
}

$ATLANTIS_GH_APP_KEY must be pulled from AWS Secret Manager.

@dosubot dosubot bot added the Stale label Oct 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality/enhancement Stale
Projects
None yet
Development

No branches or pull requests

7 participants