chamber
chamber copied to clipboard
Feature request: Exporting all services at once
Imagine the following chamber list-services
output:
Service
app/aws
app/bucket
app/secrets
Right now you cannot do chamber export app
but need to explicitly provide the service name e.g. chamber export app/aws
.
It would be nice if one could export the entire tree, using the service as a prefix.
For instance if one had such SSM parameter setup:
app/aws/region = "foo"
app/bucket/foo = "bar"
app/bucket/bar = "baz"
app/secrets/hash = "xyz"
chamber export app
could then produce something like:
AWS_REGION="foo"
BUCKET_FOO="bar"
BUCKET_BAR="baz"
SECRETS_HASH="xyz"
looks related to #334
I haven't been involved in this project previously, but would like to respond. (I'm a Segment employee.)
I reported some analysis and ideas in a related issue and I'll expand on that here.
There are a couple of problems (not insurmountable!) with the suggestion in this issue.
- chamber doesn't recurse down a path-like structure for service names anywhere at the moment, as far as I can tell. For example,
export
could produceAWS_REGION="foo"
due to some SSM parameter named "app/aws/region", butchamber exec app
orchamber list app
won't notice it. Maybe it'd be enough ifchamber import
similarly interpreted the export output as paths, but ... - When chamber converts parameter names into environment variable names (this is for the dotenv format), it converts characters besides
/
- notably.
- into underscores. At that point, there's no indication whether the underscore is a path separator or not. So, the import process wouldn't know how to construct the original hierarchy. (Maybe we'd accept that as a lossy output format that can't be reliably imported, because other formats preserve the hierarchy.)
I think a --recursive
option like I suggested in the other issue could work well here. Also, an alternative that works today is to use dot separators for the chamber keys, so for example:
chamber write app aws.region us-west-2
That leads to a parameter name "app/aws.region", so if there are other processes reading the raw parameter and expecting a nice hierarchy, well, they'd be disappointed. But, it would produce the desired AWS_REGION
environment variable name.