azurerm_static_site_custom_domain

Manages a Static Site Custom Domain.

Example Usage

CNAME validation

resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "West Europe"
}

resource "azurerm_static_site" "example" {
  name                = "example"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_resource_group.example.location
}

resource "azurerm_dns_cname_record" "example" {
  name                = "my-domain"
  zone_name           = "contoso.com"
  resource_group_name = azurerm_resource_group.example.name
  ttl                 = 300
  record              = azurerm_static_site.example.default_host_name
}

resource "azurerm_static_site_custom_domain" "example" {
  static_site_id  = azurerm_static_site.example.id
  domain_name     = "${azurerm_dns_cname_record.example.name}.${azurerm_dns_cname_record.example.zone_name}"
  validation_type = "cname-delegation"
}

TXT validation

resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "West Europe"
}

resource "azurerm_static_site" "example" {
  name                = "example"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_resource_group.example.location
}

resource "azurerm_static_site_custom_domain" "example" {
  static_site_id  = azurerm_static_site.example.id
  domain_name     = "my-domain.contoso.com"
  validation_type = "dns-txt-token"
}

resource "azurerm_dns_txt_record" "example" {
  name                = "_dnsauth.my-domain"
  zone_name           = "contoso.com"
  resource_group_name = azurerm_resource_group.example.name
  ttl                 = 300
  record {
    value = azurerm_static_site_custom_domain.example.validation_token
  }
}

Arguments Reference

The following arguments are supported:

Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

Import

Static Site Custom Domains can be imported using the resource id, e.g.

terraform import azurerm_static_site_custom_domain.example /subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.Web/staticSites/my-static-site1/customDomains/name.contoso.com