Hi,
There are multiple modules (created in Json format) defined in my project for Azure and there are inter-module dependencies to control sequence of resource creation. e.g “Resource-Group” to be created before other resource creation.
During execution, first I get error ‘At least 1 “features” blocks are required’. This forces me to include following in my script.
provider “azurerm” {
features {}
}
On adding above configuration I start getting error “Providers cannot be configured within modules using count, for_each or depends_on”.
Is there a way to define inter-module dependency? I have tried it with multiple versions of Terrraform (including the latest one 1.1.3).
Do you define the provider block also within each module?
Hi,
Module definition is in Json Format.
{
“module”: {
“rg-module”: {
“source”: “.modules\resource-group”,
“rg_name”: “test-rg”,
“location”: “westus2”,
}
}
}
And dependent module defininition
{
“module”: {
“module-2”: {
“source”: “.modules\other-resource”,
“depends_on”: [
“module.rg-module”
]
}
}
}
Terraform expects feature block to be defined in each source folder. This forces me to include “Provider” block in source location (provider “azurerm” {
features {} })
But after including this, “depends_on” starts failing (“Providers cannot be configured within modules using count, for_each or depends_on”).
Do you create the provider definition within modulese\other-resource
and modules\resource-group
and in root .
?
This is not needed.
You only have to define it within root.