4
votes

I am creating azure app services via terraform and following there documentation located at this site : https://www.terraform.io/docs/providers/azurerm/r/app_service.html

Here is the snippet for terraform script:

resource "azurerm_app_service" "app" {
  name                = "app-name"
  location            = "${azurerm_resource_group.test.location}"
  resource_group_name = "${azurerm_resource_group.test.name}"
  app_service_plan_id = "ommitted"

  site_config {
    java_version           = "1.8"
    java_container         = "TOMCAT"
    java_container_version = "8.5"
  }
  }

I need sub domain as well for my app services for which I am not able to find any help in terraform :

as of now url for app services is: https://abc.azure-custom-domain.cloud

and I want my url to be : https://*.abc.azure-custom-domain.cloud

I know this can be done via portal but is their any way by which we can do it via terraform?

3
Based on my knowledge, this is not possible. You need do it on Portal.Shui shengbao
I add it as an answer. Hope it will help more people.Shui shengbao
I think using the combination of ARM templates and Terraform it should workfocode

3 Answers

8
votes

This is now possible using app_service_custom_hostname_binding (since PR#1087 on 6th April 2018)

resource "azurerm_app_service_custom_hostname_binding" "test" {
  hostname            = "www.mywebsite.com"
  app_service_name    = "${azurerm_app_service.test.name}"
  resource_group_name = "${azurerm_resource_group.test.name}"
}
1
votes

This is not possible. You could the link you provided. If parameter is not in, the parameter is not supported by terraform.

You need do it on Azure Portal.

-2
votes

I had the same issue & had to use PowerSHell to overcome it in the short-term. Maybe you could get Terraform to trigger the PSHell script... I haven't tried that yet!!!

PSHell as follows: -

$fqdn="www.yourwebsite.com"
$webappname="yourwebsite.azurewebsites.net"
Set-AzureRmWebApp -Name <YourAppServiceName> -ResourceGroupName <TheResourceGroupOfYourAppService> -HostNames @($fqdn,$webappname) 

IMPORTANT: Make sure you configure DNS FIRST i.e. CNAME or TXT record for the custom domain you're trying to set, else PSHell & even the Azure Portal manual method will fail.