Terraform module implementation issue- no definition was found
Hello,
I'm running into the following issue when trying to use modules..
The error is for both tag names - costalloc_tags and default_tags (which worked fine before modules)
"The argument "costalloc_tags" is required, but no definition was found.
Running Terraform.exe apply -var-file="./dev/terraform.tfvars"
./dev/terraform.tfvars
default_tags ={
"Environment" = "WELP-DEV-CORP",
"managed by" = "terraform"
}
costalloc_tags ={
"CostAlloc" = "WELP-DEV-CORP-INFRA"
}
main.TF (Root)
module "VPC" {
source = "./modules/network"
cidr_block= var.vpc_cidr
enable_dns_hostnames= true
tags = merge(
var.default_tags,
var.costalloc_tags
)
}
variables.tf (Root)
variable "default_tags"{
type = map
}
variable "costalloc_tags"{
type = map
}
.\modules\network\main.tf
resource "aws_vpc" "VPC" {
cidr_block= var.vpc_cidr
enable_dns_hostnames= true
tags = merge(
var.default_tags,
var.costalloc_tags
)
}
.\modules\network\variables.tf
variable "default_tags"{
type = map
}
variable "costalloc_tags"{
type = map
}
Posted May 27, 2020, 1:43 AM UTC
14
This pass data to the variable 'tags' in the module. Thus the module is missing the required *_tags variables. You must pass both of them.
Aren't they being passed from the tfvars though?
Modules only have knowledge of what is passed to them using the 'module' statement.
Would you mind giving an example? It's just not clicking tonight.