chamber icon indicating copy to clipboard operation
chamber copied to clipboard

Feature request: Exporting all services at once

Open syphernl opened this issue 2 years ago • 2 comments

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"

syphernl avatar May 03 '22 08:05 syphernl

looks related to #334

kevcube avatar May 04 '22 18:05 kevcube

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 produce AWS_REGION="foo" due to some SSM parameter named "app/aws/region", but chamber exec app or chamber list app won't notice it. Maybe it'd be enough if chamber 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.

bhavanki avatar Mar 07 '24 22:03 bhavanki