I am deploying my Rails app to GAE, whose codes are stored in github.
Obviously, I need to hide my secret key and database password.
In Heroku, I can set them in environment variables very easily and nicely using Heroku GUI, so it won't appear in any source code or database.
What about GAE? I cannot set them in app.yaml because:
- .gitignore is not an option: Even I hide app.yaml file or alternative json file by .gitignore, I have to save it in my local computer. It means that Only I can deploy, and I have to do backup by myself. This is terrible.
- Someone says that I can store secret values in database. But I want to hide database password too.
Any idea?
I addressed this problem in an answer to a similar question. Essentially, you can create a
credentials.yaml
file alongside yourapp.yaml
and import it inapp.yaml
. This will allow you to specify your credentials as ENV variables while retaining the ability to ignore the file in git. Theincludes:
tag allows you to import an array of files in yourapp.yaml
.Example
app.yaml
:credentials.yaml
:The most secure way to store this info is using project metadata. On a Flexible/ManagedVM environment you can access the metadata via a simple http request.
From the google blog post:
ManagedVMs are the old name for what is now called 'AppEngine Flexible Environment'. Since you say you are using Ruby on App Engine you must be using Flexible/ManagedVMs. Therefore you should be able to use these 'magic URLs'.
So to get an application secret called
mysecret
in Ruby you might do:(For @joshlf) Here's how to access project metadata on AppEngine Standard Environment in Python: