terraform-provider-azurerm icon indicating copy to clipboard operation
terraform-provider-azurerm copied to clipboard

`azurerm_static_web_app_custom_domain.validation_token` dissapears after successfull validation

Open tlfzhylj opened this issue 4 months ago • 0 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

Community Note

  • Please vote on this issue by adding a :thumbsup: reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment and review the contribution guide to help.

Terraform Version

1.12.1

AzureRM Provider Version

4.33

Affected Resource(s)/Data Source(s)

azurerm_static_web_app_custom_domain

Terraform Configuration Files

resource "azurerm_static_web_app_custom_domain" "apex" {
  static_web_app_id = azurerm_static_web_app.client.id
  domain_name = "example.com"
  validation_type = "dns-txt-token"
}

resource "azurerm_dns_txt_record" "static_web_app_apex_domain_verification" {
  name                = "@"
  zone_name           = azurerm_dns_zone.main.name
  resource_group_name = azurerm_resource_group.main.name

  record {
    value = azurerm_static_web_app_custom_domain.apex.validation_token
  }
  ttl = 3600
}

Debug Output/Panic Output

│ Error: expected length of record.0.value to be in the range (1 - 4096), got 
│ 
│   with module.example.azurerm_dns_txt_record.static_web_app_apex_domain_verification[0],
│   on ../modules/example/resources.static-webapp.tf line 85, in resource "azurerm_dns_txt_record" "static_web_app_apex_domain_verification":
│   85: resource "azurerm_dns_txt_record" "static_web_app_apex_domain_verification" {
│

Expected Behaviour

I can use plan and apply after successful TXT validation by azurerm_static_web_app_custom_domain

Actual Behaviour

As long as the TXT validation is still pending (on Azure Portal), everything works perfectly.

As soon as the validation is done a terraform plan will result in Error: expected length of record.0.value to be in the range (1 - 4096), got

Steps to Reproduce

  1. terraform apply the provided configuration file
  2. Wait for TXT validation to finalize (not awaited by TF as per explicit warning in the docs) via Azure Portal
    1. Go to Azure Portal
    2. Go to Static Web Apps
    3. Go to Custom Domains
    4. Wait for your TXT "Validating" spinner to get replaced by green checkbox + "Ready" (this can take up to 12h)
  3. Try doing terraform plan or terraform apply (even without changing anything)

If you do a terraform plan -refresh-only then it is indicated that the azurerm_static_web_app_custom_domain no longer contains the validation_token.

Important Factoids

No response

References

Exactly the same as https://github.com/hashicorp/terraform-provider-azurerm/issues/14750 which is about the deprecated resource azurerm_static_site_custom_domain.

tlfzhylj avatar Jun 20 '25 05:06 tlfzhylj