Custom domain for Linux webapp deployment slot

Trying to map a custom domain to a Linux webapp deployment slot using

  • azurerm_app_service_slot_custom_hostname_binding

Production slot custom domains mapped ok, but trying to get custom subdomains mapped to the slot and getting the following error:

resource "azurerm_app_service_slot_custom_hostname_binding" "xxx_staging" {
  count               = terraform.workspace == "prod" ? 1 : 0
  app_service_slot_id = azurerm_linux_web_app_slot.staging[0].id
  hostname            = "prod.${local.xxx_apex_domain}"
  depends_on          = [azurerm_dns_txt_record.appservice_xxx_domain_verification_id]

  lifecycle {
    ignore_changes = [ssl_state, thumbprint]
  }
}
``
 
> Error: creating App Service Slot Custom Hostname Binding: (Host Name Binding Name "prod.xxx.xxx.xxx.xx" / Slot Name "staging" / Site Name "xxxxx" / Resource Group "xxxx"): web.AppsClient#CreateOrUpdateHostNameBindingSlot: Failure sending request: StatusCode=409 -- Original Error: autorest/azure: Service returned an error. Status=nil nil