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

Support SECRET_PATH as ENV #187

Open
kochanowski opened this issue Nov 19, 2018 · 7 comments
Open

Support SECRET_PATH as ENV #187

kochanowski opened this issue Nov 19, 2018 · 7 comments

Comments

@kochanowski
Copy link

It would be very useful if we could set path to the secret via environmental variable.
Now if I want to use one docker image in several projects I need to inject path with ugly sed hacks.

@tyd
Copy link
Contributor

tyd commented Nov 30, 2018

See this PR: #167 ...hopefully they can merge it soon. We're doing a custom build to have this functionality available.

@kochanowski
Copy link
Author

Thanks @tyd. Is your build available somewhere?

@tyd
Copy link
Contributor

tyd commented Dec 3, 2018

@kochanowski unfortunately not. But I'm just doing a checkout of the code from that PR and doing a build via docker based on the readme instructions

@eikenb
Copy link
Contributor

eikenb commented Aug 10, 2020

Does #167 fix this? It is merged and I'm doing a release with it right now... so if so, we should be able to close this.

@kochanowski
Copy link
Author

Hey @eikenb I'm sorry for a long response, I totally missed that, but since I'm still using envconsul in my deployments it would be great to have this feature working.

I don't see any documentation though, can you provide me some details how to test it?

BTW it's strange that tool helping provide 12-factor principles for other tools and apps itself doesn't store its config in environment variables, don't you think? :)

@eikenb
Copy link
Contributor

eikenb commented Oct 13, 2021

I don't see any documentation though, can you provide me some details how to test it?

The docs updates were pretty minimal, with a segment in the prefix section.

envconsul/README.md

Lines 358 to 361 in 1e2809c

# This tells Envconsul to use a custom formatter when building the path for
# the key from which to read data, in this case reading an environment
# variable and putting it into the path.
path = "foo/{{ env \"BAR\" }}"

Simply put, you just reference the SECRET_PATH environment variable in the prefix.path config setting. Something like..

prefix {
  path = "{{ env \"SECRET_PATH\" }}"
}

BTW it's strange that tool helping provide 12-factor principles for other tools and apps itself doesn't store its config in environment variables, don't you think? :)

Kind of is... there are sort of hacky work-arounds. Like wrapping the call in a script which takes an environment variable with a base64 encoded version of the config and writes that to a temp file before running. The main problem is that most 12-factor apps are made to have a minimal config that works with a few env-vars... and it's harder to shoehorn a large config file like envconsul has into them without resorting to tricks like above.

@TaiSHiNet
Copy link

I've tried using this in the config:

consul {
  address = "{{ env \"CONSUL_HOST\" }}:8500"
}

But no dice, it tries to parse the hostname as a literal string

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

No branches or pull requests

4 participants