Formae plugin for managing Cloudflare DNS records. Supports all major record types including A, AAAA, CNAME, MX, TXT, NS, CAA, and SRV.
| Resource Type | Description |
|---|---|
CLOUDFLARE::DNS::Record |
Cloudflare DNS record (A, AAAA, CNAME, MX, TXT, NS, CAA, SRV) |
Set these environment variables before running Formae:
export CLOUDFLARE_API_TOKEN="your-api-token"
export CLOUDFLARE_ZONE_ID="your-zone-id"To find your Zone ID:
- Log in to the Cloudflare dashboard
- Select your domain
- The Zone ID is shown in the right sidebar under "API"
To create an API token:
- Go to Cloudflare dashboard > My Profile > API Tokens
- Create a token with "Zone > DNS > Edit" permissions
Configure a target in your Forma file:
import "@cloudflare-dns/cloudflare-dns.pkl" as dns
new formae.Target {
label = "cloudflare"
namespace = "CLOUDFLARE"
config = new dns.Config {
api_token = read("env:CLOUDFLARE_API_TOKEN")
zone_id = read("env:CLOUDFLARE_ZONE_ID")
}
}| Field | Type | Required | CreateOnly | Description |
|---|---|---|---|---|
record_type |
String | Yes | Yes | Record type: A, AAAA, CNAME, MX, TXT, NS, CAA, SRV |
name |
String | Yes | Yes | DNS hostname (e.g., "www", "@" for root) |
content |
String | Yes | No | Record value (format varies by type) |
ttl |
Int | No | No | TTL in seconds (1 = automatic, default) |
proxied |
Boolean | No | No | Enable Cloudflare proxy (A/AAAA/CNAME only) |
priority |
Int | Conditional | No | Priority (required for MX and SRV) |
comment |
String | No | No | Optional note about the record |
| Type | Content Format | Example | Priority |
|---|---|---|---|
| A | IPv4 address | 192.0.2.1 |
No |
| AAAA | IPv6 address | 2001:db8::1 |
No |
| CNAME | Target hostname | target.example.com |
No |
| MX | Mail server hostname | mail.example.com |
Yes (required) |
| TXT | Text value | v=spf1 include:_spf.example.com ~all |
No |
| NS | Nameserver hostname | ns1.example.com |
No |
| CAA | CAA record value | 0 issue "letsencrypt.org" |
No |
| SRV | weight port target | 5 5060 sipserver.example.com |
Yes (required) |
new dns.DNSRecord {
label = "web-server"
record_type = "A"
name = "www"
content = "192.0.2.1"
ttl = 300
proxied = true
}new dns.DNSRecord {
label = "mail-primary"
record_type = "MX"
name = "@"
content = "mail.example.com"
ttl = 3600
priority = 10
}new dns.DNSRecord {
label = "spf-record"
record_type = "TXT"
name = "@"
content = "v=spf1 include:_spf.example.com ~all"
ttl = 3600
}new dns.DNSRecord {
label = "caa-letsencrypt"
record_type = "CAA"
name = "@"
content = "0 issue \"letsencrypt.org\""
ttl = 3600
comment = "Allow Let's Encrypt to issue certificates"
}See the examples/ directory for more complete examples.
This plugin is licensed under BSD-3-Clause. See LICENSE for details.