terraform-provider-azapi
terraform-provider-azapi copied to clipboard
`azapi_resource` uses `registry.terraform.io/hashicorp/azapi`
Hello everyone,
While using the resource azapi_resource
inside a module, I have noticed that it requires registry.terraform.io/hashicorp/azapi
, which obviously does not exist (azure/azapi
and not hashicorp/azapi
).
Parent module
terraform {
required_providers {
azapi = {
source = "azure/azapi"
}
azurerm = {
source = "hashicorp/azurerm"
}
}
}
provider "azapi" {
}
provider "azurerm" {
features {}
}
module "app_service" {
count = 2
source = "../../modules/azure_appservices"
resource_group_name = var.resource_group_name
resource_group_location = var.resource_group_location
Common_tags = var.Common_tags
connection_strings = var.connection_strings
appsettings = var.appsettings
random_value = var.random_value
application_names = var.application_names
name = "testdan-${count.index}"
}
Child module
/* [Additional code...] */
resource "azapi_resource" "siteextension1" {
type = "Microsoft.ContainerRegistry/registries@2020-11-01-preview"
name = "AspNetCoreRuntime.5.0.x64"
parent_id = azurerm_windows_web_app.example1.id
}
/* [Additional code...] */
Running the terraform providers
command reveals this odd behavior, which prevents the option to succeed with terraform init
.
.
├── provider[registry.terraform.io/azure/azapi]
├── provider[registry.terraform.io/hashicorp/azurerm]
└── module.app_service
├── provider[registry.terraform.io/hashicorp/azurerm]
└── provider[registry.terraform.io/hashicorp/azapi]
Hi @E-RELevant ,
Thank you for taking time to report this issue!
Please add the following config in your tf files before running terraform init
. It tells terraform which azapi
provider it should download.
terraform {
required_providers {
azapi = {
source = "azure/azapi"
}
}
}
Hi @E-RELevant ,
Thank you for taking time to report this issue!
Please add the following config in your tf files before running
terraform init
. It tells terraform whichazapi
provider it should download.terraform { required_providers { azapi = { source = "azure/azapi" } } }
My apologies for not mentioning it earlier, since it seems obvious that I do. This section is included, but it does not work. I've updated the original comment with the relevant information.
yes, it seems required that the azapi source is specified in every (child) module where the azapi provider is used. I was expecting that specifying the source was only required in the root module.
yes, it seems required that the azapi source is specified in every (child) module where the azapi provider is used. I was expecting that specifying the source was only required in the root module.
Can't count/foreach be used with azapi
then? I find it quite odd.
You can use count/foreach with azapi
. It works well.
The requirement for having a provider constraint in each module is documented here.
I'll close this issue, but feel free to reopen it if there's further question.