define
(define)
April 29, 2020, 9:44am
1
Hi.
I need some help with export Opennebula variables to terraform.
In a .tr file i add:
provider "opennebula" {
endpoint = "http://192.168.1.55:2633/RPC2"
username = "terraform"
password = "password"
}
Everything is working correctly.
But I don’t want to keep credentials in the .tf file, so i add the credentials to linux variables:
export TF_VAR_endpoint=http://192.168.1.55:2633/RPC2
export TF_VAR_username=terraform
export TF_VAR_password=password
But when i run terraform plan
i get:
provider.opennebula.endpoint
The URL to your public or private OpenNebula
Enter a value:
How to add variables correctly?
Bishop
(Bishop)
April 30, 2020, 2:17pm
2
I found the solution to a similar problem in the TF documentation. Are you missing a series of variable statements to link the env variables into TF?
variable "endpoint" {}
variable "username" {}
variable "password" {}
…which you then link into the code?
provider "opennebula" {
endpoint = var.endpoint
username = var.username
password = var.password
}
I’d choose better variable names, but I wrote that to match the environment that is being sent into TF by your code above.
TL;DR - you now need stubbed variable definitions to position your environment variables into the TF code, and you need to use those variables in a provider specification.