chamber
chamber copied to clipboard
feature request: Having a namespace in front of the ssm /service/ path.
Hi there!
What are the thoughts of having an ENV VAR SSM_PATH_NAMESPACE or SSM_PATH_PREPEND which prepends a string in front of the /service/lookupvar . This to make it easier to organize SSM a bit when it's not only docker applications looking up SSM. For example I'm currently using /applications/service/lookupvar.
Just trying out Chamber for the first time after reading the post on the AWS blog. Thanks for the tool (and the article), you helped me quickly get up to speed with effective patterns for using Parameter Store.
However, I support the request in this issue. Namely: Chamber doesn't support using path-based organization of my parameters, which I take to be recommended practice (based on the Parameter Store docs and examples I've seen on AWS).
In the meantime, I've got a systemd unit that does the basic version. In other words, the below fetches all parameters within a path and upcases the final segment of the path key then outputs an environment file (in the format "PATH_SEGMENT_ENV_VAR=decrypted_value"):
[Unit]
Description=Fetch app startup config from AWS Parameter Store
[Service]
Type=oneshot
Environment="PARAMETER_STORE_PATH=/this/is/my/nested/path/in/parameter_store"
Environment="RAW_PARAMETER_OUTPUT=/tmp/parameter_output.json"
Environment="PARAMETER_ENV_FILE=/run/parameter_store.env"
Environment="AWS_DEFAULT_REGION=${AWS_REGION}"
ExecStartPre=/bin/bash -c 'aws ssm get-parameters-by-path --path="${PARAMETER_STORE_PATH}" --with-decryption > ${RAW_PARAMETER_OUTPUT}'
ExecStart=/bin/bash -c 'jq -r \'.Parameters | map((.Name | split("/")[-1] | ascii_upcase) +"="+ (.Value))[]\' ${RAW_PARAMETER_OUTPUT} > ${PARAMETER_ENV_FILE}'
ExecStartPost=/usr/bin/shred -u ${RAW_PARAMETER_OUTPUT}
+1 to prefix (namespace) or at least allow '/' in service name. Currently using '/' gives an error:
Error: Failed to validate service: Failed to validate service name 'namespace/env/service'. Only alphanumeric, dashes, and underscores are allowed for service names
This might be resolved by https://github.com/segmentio/chamber/pull/118
@AndreyMarchuk Ah thanks for pointing me out!
@maartenvanderhoef I submitted https://github.com/segmentio/chamber/pull/140 as a way to add support
I think this would be a useful feature, but probably requires a change to the model, so targeting for v3.x
This issue has been automatically marked stale because it has not had any activity in the last 60 days. If no further activity occurs within 7 days, it will be closed. Closed does not mean "never", just that it has no momentum to get accomplished any time soon.
See CONTRIBUTING.md for more info.
Closing due to staleness. Closed does not mean "never", just that it has no momentum to get accomplished any time soon. See CONTRIBUTING.md for more info.
I too would like this very much to have this.
Ideally I would just like to set my own prefix in front of /service, and then I can set it via an environment variable and done. For example, it would be nice to have CHAMBER_PREFIX="/mycompany/dev" and it will do "/mycompany/dev/service".
That being said, I just wanted to add that this can kind of be done already in an awkward way by using slashes in a service name. e.g. chamber write "mycompany/dev" "foo" "bar". This appears to work well giving a /mycompany/dev/foo key in Param Store.