Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

terraform.tfvars (and CLI vars ignored) #445

Closed
serenitus opened this issue Oct 17, 2014 · 5 comments
Closed

terraform.tfvars (and CLI vars ignored) #445

serenitus opened this issue Oct 17, 2014 · 5 comments

Comments

@serenitus
Copy link

On master (35352a2):

I simply cannot get the following to work:

terraform.tfvars

environment_name = "Development"

test.tf

provider "aws" {
    access_key = "foo"
    secret_key = "bar"
    region = "us-west-1"
}

resource "aws_vpc" "VPC" {
    cidr_block = "10.0.0.0/16"
    tags {
        Name = "${var.environment_name}"
    }
}

This results in:

There are warnings and/or errors related to your configuration. Please
fix these before continuing.

Errors:

  • module root: 1 error(s) occurred:
  • resource 'aws_vpc.VPC' config: unknown variable referenced: environment_name

Manually:

$ terraform plan -var 'environment_name=Development'

Results in exactly the same error. As does:

$ terraform plan -var-file=terraform.tfvars

@pmoust
Copy link
Contributor

pmoust commented Oct 17, 2014

You have to declare environment_name in *.tf , tfvars assigns a value to a variable, it does not declare the variable, same goes with the the variable value assigning from cli.

variable "environment_name" {}

@serenitus
Copy link
Author

Haha. I totally am a giant clownshoe today. Thanks! :)

@chiefy
Copy link

chiefy commented May 17, 2015

Not sure if I was being a clownshoe, or if it's not intuitive, but I just spent a while trying to figure out why my tfvars file wasn't working. I am a n00b coming from the packer workflow where you template with straight up JSON files. Oh well, thanks for this though, it helped.

@jbarreneche
Copy link

Same here, bumped with the same problem.
I think the problem is the documentation. It doesn't say anywhere that for *.tfvars files to have any effect the variable needs to be declared in a *.tf (and it's not something intuitive, the files are tfvars).

@ghost
Copy link

ghost commented Apr 19, 2020

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.

@ghost ghost locked and limited conversation to collaborators Apr 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants