Azure App Service (Web Apps) Certificate Binding
This page shows how to write Terraform for App Service (Web Apps) Certificate Binding and write them securely.
azurerm_app_service_certificate_binding (Terraform)
The Certificate Binding in App Service (Web Apps) can be configured in Terraform with the resource name azurerm_app_service_certificate_binding
. The following sections describe 8 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "azurerm_app_service_certificate_binding" "panel" {
hostname_binding_id = var.panel_binding_id
certificate_id = azurerm_app_service_managed_certificate.panel_certificate.id
ssl_state = "SniEnabled"
}
resource "azurerm_app_service_certificate_binding" "example" {
hostname_binding_id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.Web/sites/mywebappfake/hostNameBindings/example.example.com"
certificate_id = azurerm_app_service_certificate.example.id
ssl_state = "IpBasedEnabled"
}
resource "azurerm_app_service_certificate_binding" "withoutId" {
resource "azurerm_app_service_certificate_binding" "example" {
hostname_binding_id = azurerm_app_service_custom_hostname_binding.example.id
certificate_id = azurerm_app_service_managed_certificate.example.id
ssl_state = var.ssl_state
resource "azurerm_app_service_certificate_binding" "example" {
hostname_binding_id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.Web/sites/mywebappfake/hostNameBindings/example.example.com"
certificate_id = azurerm_app_service_certificate.example.id
ssl_state = "IpBasedEnabled"
}
resource "azurerm_app_service_certificate_binding" "withoutId" {
resource "azurerm_app_service_certificate_binding" "function_custom_domain_certificate_binding" {
hostname_binding_id = azurerm_app_service_custom_hostname_binding.function_custom_domain_binding.id
certificate_id = azurerm_app_service_managed_certificate.function_custom_domain_certificate.id
ssl_state = "SniEnabled"
}
resource "azurerm_app_service_certificate_binding" "main" {
hostname_binding_id = azurerm_app_service_custom_hostname_binding.main.id
certificate_id = azurerm_app_service_managed_certificate.main.id
ssl_state = "SniEnabled"
}
resource "azurerm_app_service_certificate_binding" "custom_hostname" {
hostname_binding_id = azurerm_app_service_custom_hostname_binding.static_site.id
certificate_id = azurerm_app_service_certificate.custom_hostname.id
ssl_state = "SniEnabled"
}
resource "azurerm_app_service_certificate_binding" "function_custom_certificat_bind" {
hostname_binding_id = azurerm_app_service_custom_hostname_binding.function_custom_domain.id
certificate_id = azurerm_app_service_managed_certificate.function_managed_certificat.id
ssl_state = "SniEnabled"
}
Parameters
-
app_service_name
optional computed - string -
certificate_id
required - string -
hostname
optional computed - string -
hostname_binding_id
required - string -
id
optional computed - string -
ssl_state
required - string -
thumbprint
optional computed - string -
timeouts
single block
Explanation in Terraform Registry
Manages an App Service Certificate Binding.
Tips: Best Practices for The Other Azure App Service (Web Apps) Resources
In addition to the azurerm_app_service, Azure App Service (Web Apps) has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.
azurerm_app_service
Ensure your App Service is accessible via HTTPS only
It is better to configure the App Service to be accessible via HTTPS only. By default, both HTTP and HTTPS are available.
azurerm_function_app
Ensure to enable authentication to prevent anonymous request being accepted
It is better to enable authentication to prevent anonymous requests and ensure all communications in the application are authenticated.
Azure Resource Manager Example
Azure Resource Manager code does not have the related resource.
Frequently asked questions
What is Azure App Service (Web Apps) Certificate Binding?
Azure App Service (Web Apps) Certificate Binding is a resource for App Service (Web Apps) of Microsoft Azure. Settings can be wrote in Terraform.
Where can I find the example code for the Azure App Service (Web Apps) Certificate Binding?
For Terraform, the kashw2/Fleet-of-the-Faithful-Knights, gilyas/infracost and VentsislavDinev/en_sample source code examples are useful. See the Terraform Example section for further details.