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

Is it possible to read environment variables from yaml configuration files? #5244

Closed
spacewander opened this issue Oct 15, 2021 Discussed in #5222 · 4 comments · Fixed by #6505
Closed

Is it possible to read environment variables from yaml configuration files? #5244

spacewander opened this issue Oct 15, 2021 Discussed in #5222 · 4 comments · Fixed by #6505
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@spacewander
Copy link
Member

Discussed in #5222

Originally posted by abbluiz October 13, 2021
I want to use different configuration depending on my environment on some YAML configuration files, specially in conf/apisix.yaml in stand-alone mode. Is it possible to read from environment variable like ${VAR} inside YAML file?

@jagerzhang
Copy link
Contributor

At present, we use Python jinja2 to render config.yaml, then we can indirectly set APISIX through environment variables.
If environment variables are naturally supported, i think it is more convenient.

@abbluiz
Copy link

abbluiz commented Oct 15, 2021

Is it enough to call the function resolve_conf_var() with the 2 variables below (from file apisix/apisix/core/config_yaml.lua lines 103-104)?

apisix_yaml = apisix_yaml_new
apisix_yaml_ctime = last_change_time

Like that:

local ok, err = resolve_conf_var(apisix_yaml)
if not ok then
    return nil, err
end

local ok, err = resolve_conf_var(apisix_yaml_ctime)
if not ok then
    return nil, err
end

@spacewander
Copy link
Member Author

You can try it.

@wilson-1024
Copy link
Contributor

I want to try to implement this function, can it be assigned to me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
4 participants