Terraform AzureRM - azurerm_app_service_custom_hostname_binding
Guide to managing Azure App Service Web App Custom Domains using Terraform.
Prerequisite
An Azure Web App is required:
Declare Custom Domain
Resource Block
The local name will need setting.
resource "azurerm_app_service_custom_hostname_binding" "<local name>" {
}
Required Arguments
The required arguments are:
hostname
The hostname you wish people to use to visit your Static Web App.
hostname = "demo.dtvlinux.com"
Changing this argument will create a new custom domain resource.
app_service_name
Specifies the name of the Web App to bind the hostname to.
app_service_name = azurerm_linux_web_app.<local name>.name
Changing this argument will create a new custom domain resource.
resource_group_name
Specifies the resource group the resource should reside in.
resource_group_name = azurerm_resource_group.<local name>.name
Changing this argument will create a new custom domain resource.
Optional Arguments
Some optional arguments are:
ssl_state
Specifies the SSL type.
Valid options include IpBasedEnabled & SniEnabled.
ssl_state = "SniEnabled"
Changing this argument will create a new custom domain resource. thumbprint
needs specifying when the ssl_state has been declared.
thumbprint
Specifies the thumbprint of an azurerm_app_service_certificate to use.
thumbprint = azurerm_app_service_certificate.<local name>.thumbprint
Changing this argument will create a new custom domain resource.
Example Declaration
This is an example for declaring a custom hostname binding:
resource "azurerm_app_service_custom_hostname_binding" "bind-dtvlinux-001" {
hostname = "demo.dtvlinux.com"
app_service_name = azurerm_linux_web_app.<local name>.name
resource_group_name = azurerm_resource_group.<local name>.name
}