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

Use OCI_ prefixed environment variables (like OCI_CLI_, not TF_VAR_) #318

Open
MPV opened this issue Sep 7, 2021 · 8 comments
Open

Use OCI_ prefixed environment variables (like OCI_CLI_, not TF_VAR_) #318

MPV opened this issue Sep 7, 2021 · 8 comments
Labels
SDK Issue pertains to the SDK itself and not specific to any service

Comments

@MPV
Copy link

MPV commented Sep 7, 2021

I'm referring to this implementation:

environmentProvider := environmentConfigurationProvider{EnvironmentVariablePrefix: "TF_VAR"}

And comparing with the naming convention of the environment variables of oci-cli:
https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/clienvironmentvariables.htm#CLI_Environment_Variables

...and how other Terraform providers are able to pick up "usual" CLI environment variables:
https://registry.terraform.io/providers/hashicorp/aws/latest/docs#environment-variables
https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#full-reference

@MPV
Copy link
Author

MPV commented Sep 7, 2021

Somewhat unsure as to whether if it would be preferred to have this issue/change in this SDK repo, or in the TF provider, but it seems like the implementation originated from this repo, hence why I created it here.

@pelliu
Copy link
Member

pelliu commented Sep 8, 2021

@MPV, thank you for letting us know your question, it seems like the terraform provider related questions, even environmentProvider := environmentConfigurationProvider{EnvironmentVariablePrefix: "TF_VAR"} was contributed by TF team. I'd asked TF team to take a look, they will reply here, or you can also ask https://github.com/terraform-providers/terraform-provider-oci.

@pelliu
Copy link
Member

pelliu commented Sep 8, 2021

@varmax2511, @rashik-bhasin, and @govindrao55, could you please take a look?

@jodoglevy jodoglevy added the SDK Issue pertains to the SDK itself and not specific to any service label Sep 13, 2021
@tkellen
Copy link

tkellen commented Apr 24, 2024

💯 this is bizarre unexpected behavior that makes interaction with terraform highly confusing.

@ddevadat
Copy link
Member

is there any workaround for this. I am not able to use environment variables

@tkellen
Copy link

tkellen commented Sep 23, 2024

Out of pure curiosity, how is that possible? Environment variables are 50+ year old technology.

@ddevadat
Copy link
Member

even if we are using TF_VAR prefix, what should be the environment name variables that needs to be set. I tried with the below it didnt work

export TF_VAR_tenancy_ocid="..."
export TF_VAR_compartment_ocid="..."
export TF_VAR_user_ocid="..."
export TF_VAR_fingerprint="..."
export TF_VAR_private_key="..."

i am fairly new to using go sdk for oci

@ddevadat
Copy link
Member

i am doing like this for setting the provider. This way i dont need TF_VAR prefix

p1 := common.NewRawConfigurationProvider(
	os.Getenv("OCI_TENANCY"),
	os.Getenv("OCI_USER"),
	os.Getenv("OCI_REGION"),
	os.Getenv("OCI_FINGERPRINT"),
	os.Getenv("OCI_KEY_FILE"),
    common.String((os.Getenv("OCI_KEY_PASSPHRASE"))))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SDK Issue pertains to the SDK itself and not specific to any service
Projects
None yet
Development

No branches or pull requests

5 participants