[proposal] Add support for locally overriding env vars
- Dominant language
- Python
- Stars
- 11.1k
- Forks
- 1k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 2
Description
I'd like to override env vars in my config.json file only for local development purposes. I don't want to check in these values to source code and I don't want to modify the existing config.json.
As a concrete example, let's say I have a redis cluster in elasticache. Normally this is in a VPC, and I don't want it publicly accessible. I can configure my lambda functions in chalice to be in this VPC and deploy this code just fine.
However, for local development I'd like to point my chalice app at a dev instance of redis, perhaps running locally on my dev laptop. Right now I'm modifying my `.chalice/config.json` to override the real redis host/port with localhost, but I have to remember not to commit those changes.
### Proposal
I'd suggest adding support for a `.chalice/config.local.json`. This file is deep merged in with the existing `.chalice/config.json`. We'd also add it to the generated `.gitignore` file as part of `chalice new-project`. So if I had:
```
$ cat .chalice/config.json
{
"stages": {
"dev": {
"api_gateway_stage": "api",
"environment_variables": {
"REDIS_HOST": "https://elasticache....amazonaws.com/",
"REDIS_PORT": "1234"
},
...
}
```
I could create a local config file like this:
```
$ cat .chalice/config.local.json
{
"stages": {
"dev": {
"api_gateway_stage": "api",
"environment_variables": {
"REDIS_HOST": "localhost",
"REDIS_PORT": "5678"
},
...
}
```
and my local copy of my chalice app would use my dev instance of redis.
What do you all think? How are others solving this problem?
Contributor guide
Research direction
Start by tracing how .chalice/config.json is loaded and how chalice new-project generates the .gitignore file. Compare the proposed .chalice/config.local.json deep merge behavior with the existing stage and environment_variables configuration, then verify that local values are ignored and used during local development without changing the committed config.json.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, python, redis
- Domain
- cli, cloud
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100