Adding secret vars in config.json from exernal file
See original GitHub issueI suggest to be able to add secret information via external file (as in terraform).
For example, something like that in config.json
:
"environment_variables": {"authorization_token": var.secret_token }
And for the command line :
$chalice deploy --var-file=secret.json
Issue Analytics
- State:
- Created 4 years ago
- Reactions:11
- Comments:13 (5 by maintainers)
Top Results From Across the Web
(node.js) how to use environment variables in JSON file
I'm using a 3rd party library that needs a JSON config file, and I need to pass some env ...
Read more >How to Set Up Environment Variables using JSON files with ...
Reading environment variables is very common in software ... Let's add the following env-config.json file into the root of the project:.
Read more >Environment Variables, or Keeping Your Secrets ... - Medium
A simple way of defining multiple environment variables on your local machine is to use the dotenv package. ... Then at the entry...
Read more >How to separate your credentials, secrets, and configurations ...
This article shows how to separate your credentials and configurations from the application source code with the environment variables and ...
Read more >How to Store and Read Configuration Files Using React
Using a JSON File ... You can store the configuration data in a JSON file. ... Just like a component, the JSON file...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I would argue that storing credentials in config (even external, git-ignored) is not a good idea in general. Especially since you could use AWS ecosystem for that.
If not using AWS Secrets Manager, that could be expensive if you have a lot of secrets, you could easily place them in AWS SSM Parameter Store (and encrypt with default or dedicated key). And in the python code retrieving them is no more complicated than doing
os.environ['my_secret']
. Namely:And you need to specify permissions in
config-prod.json
:Other benefits of this approach are:
@jamesls , the last comment on this is from Mar 25. I generally agree with @vfilimonov 's comments on this, that using AWS tools is a better way to do this.
But if someone wants to keep their Lambda setup simple, like I do, then there is still value in allowing config.json to be able to dynamically set up environment variables to configure inside the Lambda at deploy time.
That would let some configurations flow from GitHub actions or GitLab instead of relying on an extra layer of configuration inside SSM.
It is helpful to those who run the entire test setup on Docker containers inside the CI/CD sever, outside of the AWS ecosystem, for example.
For example, all I would like here for ‘chalice deploy’ to copy some behaviour of docker-compose. In docker-compose, if you leave the value of an environment variable empty, it will try to get the value from the shell. And so config.json could just look like this.
Note that the injected key is just a list and you could default the value to empty if nothing is obtained from the shell.
I think that even a simple enhancement like that would certain workflows which want to keep it simple.