terraform error: missing required argument

132 views Asked by At

is tfvars file supposed to be in same folder where var.tf file is defined? my file structure is like this:

root
  main.tf
  rds
    rds.tf
    var.tf
  config-var
    dev.tfvars

in main.tf: RDS module is called like this without db_pass variable reference:

module "rds" {
  source = "./rds"
}

if this structure is correct then why am I getting this error when doing terraform plan -var-file="config-var/dev.tfvars". Am I missing something here.

my var is defined in var.tf without default value and then passing the value from tfvars file:

 Error: Missing required argument
│ 
│   on main.tf line 39, in module "rds":
│   39: module "rds" {
│ 
│ The argument "db_pass" is required, but no definition was found. 

I tried creating same variable in root folder and passing to rds module block.

0

There are 0 answers