Terraform: Being prompted for variable values, when the *.tfvars is present

Created on 14 Apr 2017  ยท  3Comments  ยท  Source: hashicorp/terraform

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.

Terraform Version

v0.9.3

Affected Resource(s)

None

Terraform Configuration Files

$ 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"

Debug Output

Don't know how to do that.

Expected Behavior

Values taken from *.tfvars

Actual Behavior

Prompted for values

Steps to Reproduce

  1. terraform apply

Important Factoids

Running in EC2 Classic
Windows 7

core windows

Most helpful comment

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.

All 3 comments

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.

Was this page helpful?
0 / 5 - 0 ratings