oracle/oci-go-sdk

TF_VAR in environment should override config files to avoid need for temporary edits to config

Closed this issue · 6 comments

func DefaultConfigProvider() ConfigurationProvider {

Configuration is processed by first examining config file then, if needed, environment. Thus, to temporarily use another configuration one must remove or edit the config file. I propose the environment values TF_VAR_etc. should override anything found in the config file if set.

hi @jeliker what're the TF_VAR you were referring here? Are they terraform configs, if yes, you might want to check here: https://github.com/terraform-providers/terraform-provider-oci

In general, if you want to use different configs and avoid edit config files you can do either of followings:

  1. add new profile in your config and switch different profiles in your code;
  2. write your own ConfigurationProvider with the customized logic you need;

Thanks @jeliker for the reply.

From SDK perspective, we don't know what kind of TF env variables are and TF will have full control about use the variable in config file or via env variable. And that's the reason we give control to customers to provide their own ConfigurationProvider to do customization instead of changing the default behavior for it.

As I recommended before for the two approaches, TF can use either one to achieve this. Thoughts?

Hi @jeliker I am closing this issue, let me know if you still have questions, thanks!

MPV commented

FYI I opened #318 (somewhat related to this issue, in case you'd be interested)