I have terraform configuration that looks like this
variable "heroku_api_key" {}
provider "heroku" {
email = "[email protected]"
api_key = "${var.heroku_api_key}"
}
resource "heroku_app" "default" {
name = "judge-re"
region = "us"
}
On travis I encrypted the security key like this and in the log I see that it being exported
$ export TF_VAR_HEROKU_API_KEY=[secure]
On deploy I execute this script
#!/bin/bash
set -o errexit -o nounset
terraform init
terraform plan
terraform apply
But it stalls because terraform asks for the variable
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
var.heroku_api_key
Enter a value:
The log itself is here https://travis-ci.org/lapots/judge-rule-engine/builds/342694628
The project files is here https://github.com/lapots/judge-rule-engine
What is the problem?
Hi @lapots! Sorry for the confusing behavior here.
I believe the issue is that Terraform matches the environment variables case-sensitively, so you need to name the variable as it is named in the Terraform config:
$ export TF_VAR_heroku_api_key=[secure]
oh! Indeed it works now. Guess I missed somewhere in the documentation that variable names are case sensitive
Thanks for following up, @lapots!
Indeed it seems that the documentation doesn't currently mention that _explicitly_ and instead just implies it by showing lowercase names in the examples.
We're planning a big revamp of the configuration documentation as part of our current efforts to improve the configuration language so we'll revise the relevant section as part of that work, and try to be more explicit about what is required here.
It sounds like you have what you need for now, so I'm going to close this. Sorry the documentation wasn't clearer!
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
Hi @lapots! Sorry for the confusing behavior here.
I believe the issue is that Terraform matches the environment variables case-sensitively, so you need to name the variable as it is named in the Terraform config: