Skip to content

Cloud Services

Jeff edited this page Apr 9, 2024 · 2 revisions

Because most cloud services don't give you the ability to manually send files to a deploy that aren't included in your git repo, theoretically you won't be able send your private key in order for them to be decyprted.

Fortunately Chamber gives you another option.

Once you've read up on how Chamber loads keys from environment variables, you're going to want to know how to get those environment variables to your service. Each service will have a different process but I will attempt to keep information about how to do it for the most popular services here. Feel free to submit a pull request if anything needs added or modified.

Heroku

heroku config:set --app="yourapp" CHAMBER_KEY="$(cat .chamber.pem)"

and you would repeat that command for all the keys you'd like to upload.

Travis

For Travis you actually encrypt the key file with your Travis key, then add a bit of script to your .travis.yml to make it decrypt during the build.

gem install travis

travis encrypt-file --add before_install .chamber.pem .chamber.pem.travis

The new file and changes to your .travis.yml file are then committed to the repository.

CircleCI

For CircleCI you have to know that it doesn't support multi-line environment variables, and because the keys are multi-line, you need to know what to do to deal with that.

username="jeff"
project="myproject"
circle_api_token="1234567890"

curl --request "POST" "https://circleci.com/api/v1.1/project/github/${username}/${project}/envvar?circle-token=${circle_api_token}" \
     --header  "Content-Type: application/json" \
     --verbose \
     --data    @- << EOF
       {
         "name":  "CHAMBER_KEY",
         "value": "$(cat .chamber.pem | perl -p -e 's/\n/\\n/g')"
       }
EOF

And then you have to remember to add a code snippet to your CircleCI configuration:

machine:
  post:
    - "echo 'IFS=\"|\" && export CHAMBER_KEY=\"$(echo -e $CHAMBER_KEY)\"' >> .circlerc"

to make it convert the environment variable on launch.

Clone this wiki locally