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

Required variable not set: variable despite the fact that the variables and values are already defined #15894

Closed
jpdoria opened this issue Aug 23, 2017 · 5 comments

Comments

@jpdoria
Copy link

jpdoria commented Aug 23, 2017

Terraform Version

Terraform v0.10.2

Terraform Configuration Files

terraform.tfvars

aws_access_key = "XXXXXX"
aws_secret_key = "XXXXXX"
aws_key_path = "/Users/user/.ssh/XXXXXX.pem"
aws_key_name = "XXXXXX"
aws_iam_role = "arn:aws:iam::XXXXXX:role/XXXXXX"
aws_role_session = "XXXXXX"
aws_region = "us-east-1"

vars.tf

variable "aws_region" {}
variable "aws_access_key" {}
variable "aws_secret_key" {}
variable "aws_key_path" {}
variable "aws_key_name" {}
variable "aws_iam_role" {}
variable "aws_role_session" {}

provider.tf

provider "aws" {
  version    = "~> 0.1"
  access_key = "${var.aws_access_key}"
  secret_key = "${var.aws_secret_key}"
  region     = "${var.aws_region}"

  assume_role = {
    role_arn     = "${var.aws_iam_role}"
    session_name = "${var.aws_role_session}"
  }
}

Project Structure

terraform
├── dev
│   ├── main.tf
│   ├── provider.tf
│   ├── terraform.tfvars
│   ├── terraform_remote_state.tf
│   └── vars.tf
├── modules
│   ├── eb
│   │   ├── ha
│   │   └── single
│   │       ├── main.tf
│   │       ├── outputs.tf
│   │       └── vars.tf
│   ├── r53
│   │   ├── main.tf
│   │   ├── outputs.tf
│   │   └── vars.tf
│   ├── rds
│   │   ├── main.tf
│   │   ├── outputs.tf
│   │   └── vars.tf
│   └── vpc
│       ├── main.tf
│       ├── outputs.tf
│       └── vars.tf
├── prod 
├── qa

Expected Behavior

Terraform should be able to read the variables

Actual Behavior

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

Errors:

  * 7 error(s) occurred:

* Required variable not set: aws_access_key
* Required variable not set: aws_secret_key
* Required variable not set: aws_key_path
* Required variable not set: aws_key_name
* Required variable not set: aws_iam_role
* Required variable not set: aws_role_session
* Required variable not set: aws_region
#

Steps to Reproduce

terraform validate

Workaround

vars.tf

variable "aws_region" {
  default = "foo"
}

variable "aws_access_key" {
  default = "foo"
}

variable "aws_secret_key" {
  default = "foo"
}

variable "aws_key_path" {
  default = "foo"
}

variable "aws_key_name" {
  default = "foo"
}

variable "aws_iam_role" {
  default = "foo"
}

variable "aws_role_session" {
  default = "foo"
}
@apparentlymart
Copy link
Contributor

Hi @jpdoria! Sorry this isn't working as expected.

I think this might be the same issue as #15733. If so, the workaround until that's fixed would be to explicitly specify the vars file:

$ terraform validate -var-file=terraform.tfvars

@sdot257
Copy link

sdot257 commented Oct 9, 2017

I'm having the same issues with v0.10.7

@dev-drprasad
Copy link

I am also having the same issues with v0.10.7

@apparentlymart
Copy link
Contributor

Hi all,

We added a fix for this in #15938 which was confirmed as fixed in v0.10.5 per discussion on #15733. It looks like some of you have a problem with similar symptoms, but the cause must be different if it's still present after v0.10.5.

In order to understand what's different about your situation, could one of you please open a new top-level issue with the details requested by the issue template? That way we will hopefully have enough information to reproduce the issue, whereas the details given in the description of this one no longer seem to reproduce.

Thanks!

@ghost
Copy link

ghost commented Apr 6, 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 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants