Terraform and DNS SPF record macro

Hi there,

I ran into a problem while using Terraform to update Cloudflare DNS SPF record, with macros.

Terraform Resource is :

resource "cloudflare_record" "mydomain_SPF_record" {
  name    = "mydomain.biz"
  proxied = false
  ttl     = 1800
  type    = "TXT"
  value   = "v=spf1 include:%{ir}.%{v}.%{d}.spf.has.pphosted.com include:_spf.google.com ~all"
  zone_id = "xxxxa7a1df5cf6105f1a7yyy"
}

Error when run terraform plan

$ terraform plan 
Error: Invalid template control keyword
│ 
│   on cloudflare_record.tf line 227, in resource "cloudflare_record" "mydomain_SPF_record":
│  227:   value   = "v=spf1 include:%{ir}.%{v}.%{d}.spf.has.pphosted.com include:_spf.google.com ~all"
│ 
│ "ir" is not a valid template control keyword. Did you mean "if"?```

I appreciate any help or tip.
Thank you

Versions
$ terraform -v
Terraform v1.1.6
on darwin_amd64
+ provider registry.terraform.io/cloudflare/cloudflare v3.9.1

What is SPF Macro

never mind … I found the solution how to escape the SPF macro. It requires to pad % with another %.

Below is the working code for a Resource :

resource "cloudflare_record" "mydomain_spf_record" {
  name    = "mydomain.biz"
  proxied = false
  ttl     = 1800
  type    = "TXT"
  value   = "v=spf1 include:%%{ir}.%%{v}.%%{d}.spf.has.pphosted.com include:_spf.google.com ~all"
  zone_id = "xxxxxxxxxxxxxxxxxxxxxxxx"
}

Reference from terraform.io