azureterraformterraform-provider-azure

Why I can't create azurerm_app_service connection?


Azurerm provider version

3.35.0

Target resource

azurerm_app_service_connection

Terraform file

write brief

module "app_service" {
  source               = "../../modules/app_service"
  name                 = var.name
}

resource "azurerm_app_service_connection" "serviceconnector" {
  name               = "serviceconnector"
  app_service_id     = module.app_service.id
  target_resource_id = data.azurerm_postgresql_flexible_server.db.id
  client_type        = "django"
  authentication {
    type   = "secret"
    name   = var.db_uname
    secret = data.azurerm_key_vault_secret.secret.value
  }
}

data "azurerm_postgresql_flexible_server" "db" {
  name                = "postgre"
  resource_group_name = "rg"
}

Output Error message

Error: creating Scoped Linker (Resource Uri: "/subscriptions/<id>/resourceGroups/app/providers/Microsoft.Web/sites/app_service"
│ Linker Name: "serviceconnector"): performing LinkerCreateOrUpdate: servicelinker.ServiceLinkerClient#LinkerCreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: Code="TargetTypeNotSupported" Message="Target resource type MICROSOFT.DBFORPOSTGRESQL/FLEXIBLESERVERS is not supported."
│ 
│   with azurerm_app_service_connection.serviceconnector,
│   on app_service.tf line 10, in resource "azurerm_app_service_connection" "serviceconnector":
│   10: resource "azurerm_app_service_connection" "serviceconnector" {
│ 
│ creating Scoped Linker (Resource Uri:
│ "/subscriptions/<id>/resourceGroups/app/providers/Microsoft.Web/sites/app_service"
│ Linker Name: "serviceconnector"): performing LinkerCreateOrUpdate:
│ servicelinker.ServiceLinkerClient#LinkerCreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error:
│ Code="TargetTypeNotSupported" Message="Target resource type MICROSOFT.DBFORPOSTGRESQL/FLEXIBLESERVERS is not
│ supported."

I want to ask

I updated azurerm provider to 3.35.0 by see this info.azurerm_app_service_connection: Expected type object but found type string

Why return "TargetTypeNotSupported" this message. It seems to supported as long as I saw. azurerm_app_service_connection It's my fault? or bug?


Solution

  • I have tested this in my local and landed up with error targettypenotsupported.

    If we want to create a service connection to postgressql flexible server db with app service then db should be declared using resource block only since as per this terraform documentation we dont have any definition to use datablock to create a connection with existing postgres sql flexible server db as shown in this image

    enter image description here