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 option to not fail when region and prefix are not set #8

Open
nvllsvm opened this issue Nov 20, 2018 · 0 comments
Open

Add option to not fail when region and prefix are not set #8

nvllsvm opened this issue Nov 20, 2018 · 0 comments

Comments

@nvllsvm
Copy link
Contributor

nvllsvm commented Nov 20, 2018

I would like env-aws-params to run the target command as-is if the prefix and region are not set.

Conditions

  • Neither the --aws-region flag nor the AWS_REGION environment variable are set.
  • Neither the --prefix flag nor the PARAMS_PREFIX environment variable are set.

Current Behavior
Program aborts and does execute target command.

$ env-aws-params service
ERROR: prefix is required

Desired Behavior
Program warns of missing variables and executes target command without retrieving variables.

$ env-aws-params --ignore-no-config service
WARNING: SSM variables not set

Why
I'm conditionally using env-aws-params in a Docker entrypoint script to execute the Docker command as-is if neither the PARAMS_PREFIX and AWS_REGION variables are set. This allows me to use the same container in both production and a fully local environment; the container won't reach out to SSM unless both previous mentions env vars are set.

The entrypoint script is fairly generic as it only inspects variables used by env-aws-params. However, it ends up becoming a copy/paste snippet of code that gets carried around to multiple projects. It also must be an external file to be able to safely pass "$@" to it.

COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
#!/usr/bin/env sh
if [ -n "${PARAMS_PREFIX}" ] && [ -n "${AWS_REGION}" ]; then
    exec env-aws-params "$@"
else
    exec "$@"
fi

Solution
Add a command-line flag to env-aws-params to do essentially the same thing.

ENTRYPOINT ["env-aws-params", "--ignore-no-config"]

I don't have a preference how this option is set; the name --ignore-no-config was picked without much thought put into it.

If you're open to including this, I'll glady take on development.

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

No branches or pull requests

1 participant