I am trying to create Application ID URI
of an application registration that is already deployed to Azure and using azapi
for that as Application ID URI is going to be the app's own application_id (i.e. api://[app_id]
). So I am trying to accomplish this via azapi
.
However I get following error when I run terraform init -upgrade
:
│ Error: Failed to query available provider packages
│
│ Could not retrieve the list of available versions for provider hashicorp/azapi: provider registry registry.terraform.io does not have a provider
│ named registry.terraform.io/hashicorp/azapi
│
│ Did you intend to use azure/azapi? If so, you must specify that source address in each module which requires that provider. To see which modules
│ are currently depending on hashicorp/azapi, run the following command:
│ terraform providers
I have my provider.tf
file as follows:
terraform {
required_providers {
azapi = {
source = "Azure/azapi"
}
azuread = {
source = "hashicorp/azuread"
}
azurerm = {
source = "hashicorp/azurerm"
}
}
backend "azurerm" {
#..... #necessary info
}
}
provider "azuread" {
tenant_id = "tenant_id"
}
provider "azapi" {
subscription_id = "subscription_id"
tenant_id = "tenant_id"
}
and main.tf
like so (where app_reg
is already defined):
resource "azapi_update_resource" "update_app_reg" {
type = "Microsoft.Web/sites@2022-03-01"
name = "app-reg"
parent_id = azuread_service_principal.app_reg_service_principal.object_id
# Update Application ID URI
body = jsonencode({
"properties" = {
"identifierUris" = [
"api://${azuread_application.app_reg.application_id}"
]
}
})
depends_on = [azuread_application.app_reg]
}
when I remove resource "azapi_update_resource" .........
, terraform init -upgrade
runs successfully. However when I leave it defined as it is, I get the error above.
I have already defined the provider and I am not sure what I am doing wrong. Any help would be appreciated.
PS: I have checked this post, microsoft documentation about this and hashicorp documentation about this, but nothing helpful...