Following this: https://www.terraform.io/intro/getting-started/variables.html
I have a *.tfvars file, but am being prompted for the values. When I give the values it does work correctly.
v0.9.3
None
$ cat poptart.tf
provider "aws" {
access_key = "${var.access_key}"
secret_key = "${var.secret_key}"
region = "${var.region}"
}
resource "aws_instance" "example" {
ami = "ami-656be372"
instance_type = "t1.micro"
provisioner "local-exec" {
command = "echo ${aws_instance.example.public_ip} > ip_address.txt"
}
}
resource "aws_eip" "ip" {
instance = "${aws_instance.example.id}"
}
$ cat poptart.conf.tf
variable "access_key" {}
variable "secret_key" {}
variable "region" {
default = "us-east-1"
}
$ cat poptart.tfvars
access_key = "ABC"
secret_key = "XYZ"
Don't know how to do that.
Values taken from *.tfvars
Prompted for values
terraform applyRunning in EC2 Classic
Windows 7
Hi @KidPluto,
Only the terraform.tfvars file is loaded automatically. If you want to use other filenames, you need to specify them with -var-file flag.
You are correct, thanks.
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 @KidPluto,
Only the
terraform.tfvarsfile is loaded automatically. If you want to use other filenames, you need to specify them with-var-fileflag.