Home > Enterprise >  Azure DNS - Terraform - Ignore TXT Value
Azure DNS - Terraform - Ignore TXT Value

Time:11-03

I have some terrform code which works, but i want to able to ignore the DNS TXT Record value as this is updated externally using another tool (acme.sh), I have tried multiple differnt types of HCL to ignore the value, the terraform HCL does not fail, just set's the value back to the original value

Any help would be appreciated.

resource "azurerm_resource_group" "mydomain-co-uk-dns" {
  name     = "mydomain.co.uk-dns"
  location = "North Europe"
}

resource "azurerm_dns_zone" "mydomaindns" {
  name                = "mydomain.co.uk"
  resource_group_name = azurerm_resource_group.mydomain-co-uk.name
}


resource "azurerm_dns_txt_record" "_acme-challenge-api" {
  name                = "_acme-challenge.api"
  zone_name           = azurerm_dns_zone.mydomaindns.name
  resource_group_name = azurerm_resource_group.mydomain-co-uk-dns.name
  ttl                 = 300
  record {
    value = "randomkey-that-changes externally"
  }
  tags = {
    Environment = "acmesh"
  }
  lifecycle {
    ignore_changes = [
      record
    ]
  }
}

Thanks

CodePudding user response:

I tried testing using the same code that you have provided and was successfully able to deploy the resources , then manually changed the value of record for portal and applied the terraform code again and it didn't do any changes just changed the value of the previous record to the newer value changes from portal in the terraform state file.

Image

image

image

Note: I used Terraform v1.0.5 on windows_amd64 provider registry.terraform.io/hashicorp/azurerm v2.83.0.

As confirmed by @Lain , the issue was resolved after upgrading the azurerm from 2.70.0 to latest.

  • Related