Having an issue with Terraform modules and variables and I am at a loss as to what I am doing wrong.
I have a folder structure that looks like this;
Accounts
|_____Account1
| Main.tf
| terraform.tfvars
|_____Account2
|_____Account3
|_____Modules
|________VPC
Main.tf
Variables.tf
In my modules folder I have my main.tf and variables.tf, under the accounts I also have my main.tf (calling module vpc) and terrform.tfvars.
How can I use my terraform.tfvars to pass secure credentials to my main.tf, within my accounts folder?
Variables in my Variables.tf within the VPC module look like so;
variable "aws_access_key" {
default = ""
}
Within my account folders, in the Main.tf I am trying to call tfvars this way;
variable "aws_access_key" {}
module "VPC" {
source = "/Accounts/Modules/VPC"
aws_access_key = "${var.aws_access_key}"
}
Can run terraform init without any issues but trying to run terraform plan, it just comes up in red and fails to run. This does work if I enter the variables into my main.tf within the account folder manually. But I want to strip out anything sensitive into a .tfvars file, that will end up else where.
I hope I am doing something obviously wrong! Have also tried the -var-file=terraform.tfvars switch from within account1's folder.
Any idea's would be great. As everything I read tend to imply this should be working.
Thanks Stephen
terraform plan
line in your console and the first few lines of the output after? I feel like I've had a client run into something like this before, hoping seeing that might jog my memory. – jstill