Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add -print flag #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add -print flag #52

wants to merge 1 commit into from

Conversation

aengelas
Copy link
Contributor

Add a -print flag which accepts no additional arguments and prints any found SSM env vars to stdout instead of exec-ing a process with the env vars set.

-print
      Print the decrypted env vars without exporting them and exit

The use-case for this is in places like CI jobs where you may want to resolve SSM parameters and then write them to a config file, or persist them elsewhere for subsequent use.

ssm-env is already a bit architecturally overloaded, and this strains it further. I'm not inclined to do a major refactor/rewrite at this point, but if we want to continue extending it that may be required at some point. I'd prob start by separating the interfaces for outputs and fallibility to avoid overloading the expandEnviron/setEnviron functions the way they currently are.

@isobit
Copy link
Contributor

isobit commented Dec 12, 2023

Why not just use env or printenv as an exec process? I'd prefer to keep the tool simpler if we can achieve this more generally with existing features/composition.

@aengelas
Copy link
Contributor Author

Because I don't want all the env vars. This allows only printing the actual ssm parameters. This is running between circle jobs, and there could be other env vars in scope that we don't necessarily want to persist across jobs.

@aengelas
Copy link
Contributor Author

And this seemed like a reasonable feature to support, vs. trying to do some mix of printenv and grep, xargs, etc. to achieve a similar result.

Add a -print flag which accepts no additional arguments and prints any
found SSM env vars to stdout instead of exec-ing a process with the env
vars set.

```sh
-print
      Print the decrypted env vars without exporting them and exit
```

The use-case for this is in places like CI jobs where you may want to
resolve SSM parameters and then write them to a config file, or persist
them elsewhere for subsequent use.

ssm-env is already a bit architecturally overloaded, and this strains it
further. I'm not inclined to do a major refactor/rewrite at this point,
but if we want to continue extending it that may be required at some
point. I'd prob start by separating the interfaces for outputs and
fallibility to avoid overloading the expandEnviron/setEnviron functions
the way they currently are.
@isobit
Copy link
Contributor

isobit commented Dec 12, 2023

The use-case for this is in places like CI jobs where you may want to resolve SSM parameters and then write them to a config file, or persist them elsewhere for subsequent use.
there could be other env vars in scope that we don't necessarily want to persist across jobs

Maybe more of a discussion for that use case than the feature here, but I'm concerned that conflating "vars that are substituted by ssm-env" and "vars that need to be persisted in CI" might create confusion later; e.g. it's not clear from just the CI config which vars would be persisted, and it wouldn't be clear how to exclude ssm vars or include non-ssm vars. Have you considered using a script with an explicit list of vars?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants