Hello! I am facing a problem trying to use environmental variables to set terraform variables with the prefix TF_VAR_
This is my .env
TF_VAR_test=test
This is my _env.tf
variable "test"{
type = string
}
This is my main.tf:
terraform {
cloud {
organization = "CarlosAlejandroGuerreroMartinez"
workspaces {
name = "pokemon-team-manager-github-actions"
}
}
}
This is the output:
(base) carloswarrior@Carloss-MacBook-Pro devops % source .env
(base) carloswarrior@Carloss-MacBook-Pro devops % echo $TF_VAR_test
test
(base) carloswarrior@Carloss-MacBook-Pro devops % terraform plan
Running plan in Terraform Cloud. Output will stream here. Pressing Ctrl-C
will stop streaming the logs, but will not stop the plan running remotely.
Preparing the remote plan...
To view this run in a browser, visit:
https://app.terraform.io/app/CarlosAlejandroGuerreroMartinez/pokemon-team-manager-github-actions/runs/run-7SC5B4eqg3ySq4Kv
Waiting for the plan to start...
Terraform v1.6.3
on linux_amd64
Initializing plugins and modules...
╷
│ Error: No value for required variable
│
│ on _env.tf line 10:
│ 10: variable "test"{
│
│ The root module input variable "test" is not set, and has no default value.
│ Use a -var or -var-file command line argument to provide a value for this
│ variable.
╵
Operation failed: failed running terraform plan (exit 1)
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take exactly these actions if you run "terraform apply" now.