Problem is when i call the terraform plan on main.tf in root that is calling the modules, it returns the error that he doesnt see any variables⦠What might be a problem? Thank you.
variable "cosmosdb_resource_group_name" {
description = "Name of the resource group in which to create the Cosmos DB account."
type = string
}
variable "cosmosdb_resource_group_location" {
description = "Location for the resource group."
type = string
}
variable "cosmosdb_account_name" {
description = "Name of the Cosmos DB account."
type = string
}
variable "cosmosdb_offer_type" {
description = "Offer type for the Cosmos DB account."
type = string
}
variable "cosmosdb_kind" {
description = "Kind for the Cosmos DB account."
type = string
}
variable "cosmosdb_consistency_level" {
description = "Consistency level for the Cosmos DB account."
type = string
}
variable "cosmosdb_consistency_max_interval" {
description = "Max interval in seconds for consistency."
type = number
}
variable "cosmosdb_consistency_max_staleness" {
description = "Max staleness prefix for consistency."
type = number
}
variable "cosmosdb_geo_location" {
description = "Geo location for the Cosmos DB account."
type = list(object({
location = string
failover_priority = number
}))
}
variable "cosmosdb_database_name" {
description = "Name of the Cosmos DB database."
type = string
}
variable "cosmosdb_database_throughput" {
description = "Throughput for the Cosmos DB database."
type = number
}
variable "tags" {
description = "Tags to be assigned to the Cosmos DB account."
type = map(string)
}
Error: Reference to undeclared input variable
β
β on main.tf line 4, in module "cosmosdb":
β 4: cosmosdb_resource_group_name = var.cosmosdb_resource_group_name
β
β An input variable with the name "cosmosdb_resource_group_name" has not been declared. This variable can be declared with a variable
β "cosmosdb_resource_group_name" {} block.
β΅
β·
β Error: Reference to undeclared input variable
β
β on main.tf line 5, in module "cosmosdb":
β 5: cosmosdb_resource_group_location = var.cosmosdb_resource_group_location
β
β An input variable with the name "cosmosdb_resource_group_location" has not been declared. This variable can be declared with a variable
β "cosmosdb_resource_group_location" {} block.
β΅
β·
β Error: Reference to undeclared input variable
β
β on main.tf line 6, in module "cosmosdb":
β 6: cosmosdb_account_name = var.cosmosdb_account_name
β
β An input variable with the name "cosmosdb_account_name" has not been declared. This variable can be declared with a variable
β "cosmosdb_account_name" {} block.
β΅
β·
β Error: Reference to undeclared input variable
β
β on main.tf line 7, in module "cosmosdb":
β 7: cosmosdb_kind = var.cosmosdb_kind
β
β An input variable with the name "cosmosdb_kind" has not been declared. This variable can be declared with a variable "cosmosdb_kind" {}
β block.
β΅
β·
β Error: Reference to undeclared input variable
β
β on main.tf line 8, in module "cosmosdb":
β 8: cosmosdb_database_name = var.cosmosdb_database_name
β
β An input variable with the name "cosmosdb_database_name" has not been declared. This variable can be declared with a variable
β "cosmosdb_database_name" {} block.
β΅
β·
β Error: Reference to undeclared input variable
β
β on main.tf line 9, in module "cosmosdb":
β 9: cosmosdb_database_throughput = var.cosmosdb_database_throughput
β
β An input variable with the name "cosmosdb_database_throughput" has not been declared. This variable can be declared with a variable
β "cosmosdb_database_throughput" {} block.
β΅
β·
β Error: Reference to undeclared input variable
β
β on main.tf line 10, in module "cosmosdb":
β 10: cosmosdb_offer_type = var.cosmosdb_offer_type
β
β An input variable with the name "cosmosdb_offer_type" has not been declared. This variable can be declared with a variable
β "cosmosdb_offer_type" {} block.
β΅
β·
β Error: Reference to undeclared input variable
β
β on main.tf line 11, in module "cosmosdb":
β 11: cosmosdb_consistency_level = var.cosmosdb_consistency_level
β
β An input variable with the name "cosmosdb_consistency_level" has not been declared. This variable can be declared with a variable
β "cosmosdb_consistency_level" {} block.
β΅
β·
β Error: Reference to undeclared input variable
β
β on main.tf line 12, in module "cosmosdb":
β 12: cosmosdb_consistency_max_interval = var.cosmosdb_consistency_max_interval
β
β An input variable with the name "cosmosdb_consistency_max_interval" has not been declared. This variable can be declared with a variable
β "cosmosdb_consistency_max_interval" {} block.
β΅
β·
β Error: Reference to undeclared input variable
β
β on main.tf line 13, in module "cosmosdb":
β 13: cosmosdb_consistency_max_staleness = var.cosmosdb_consistency_max_staleness
β
β An input variable with the name "cosmosdb_consistency_max_staleness" has not been declared. This variable can be declared with a variable
β "cosmosdb_consistency_max_staleness" {} block.
β΅
β·
β Error: Reference to undeclared input variable
β
β on main.tf line 14, in module "cosmosdb":
β 14: cosmosdb_geo_location = var.cosmosdb_geo_location
β
β An input variable with the name "cosmosdb_geo_location" has not been declared. This variable can be declared with a variable
β "cosmosdb_geo_location" {} block.
β΅
β·
β Error: Reference to undeclared input variable
β
β on main.tf line 15, in module "cosmosdb":
β 15: tags = var.tags
β
β An input variable with the name "tags" has not been declared. This variable can be declared with a variable "tags" {} block.
β΅
Input variables defined in the root module are ones that get values from outside the Terraform configuration - e.g. from your terraform.tfvars file.
Input variables defined in child modules get their input from assignments inside module blocks.
Since you want to do both of these things, for each of these variables, you need a variable block in the root module and another identical variable block in modules/cosmosdb/.