Sets DNS records on Netlify for the specified domain
using the
createDnsRecord
endpoint of Netlify's RESTful API. DNS records
must be provided as a dataframe/tibble with the columns
type
, hostname
, value
, ttl
, priority
, weight
, port
, flag
and tag
. Further columns are silently ignored.
Usage
netlify_dns_records_set(
records,
domain,
token = pal::pkg_config_val("netlify_token"),
max_tries = 3L
)
Arguments
- records
DNS records. A dataframe/tibble with the columns
type
,hostname
,value
,ttl
,priority
,weight
,port
,flag
andtag
. The first three columns are mandatory, columns not listed here are silently ignored.- domain
Domain name to set DNS records for. This is translated into the corresponding Netlify DNS Zone. A character scalar.
- token
Netlify personal access token used for authentication. A character scalar.
- max_tries
Maximum number of attempts to retry in case of an HTTP error. An integerish scalar.
Value
The newly set DNS records.
A tibble with the columns id
, dns_zone_id
, site_id
, managed
, type
, hostname
, value
, ttl
, priority
, weight
, port
, flag
, and tag
, invisibly.
Details
Supported are the DNS record types A
, AAAA
, ALIAS
, CAA
, CNAME
, MX
, NS
, SPF
, SRV
and TXT
. Netlify's own custom record
types NETLIFY
and NETLIFY6
cannot be altered via the API and must be configured via Netlify's web interface.
See also
Other Netlify functions:
netlify_dns_records_delete()
,
netlify_dns_records_get()
Examples
if (FALSE) { # \dontrun{
tibble::tribble(
~type, ~hostname, ~value, ~ttl, ~priority, ~weight, ~port, ~flag, ~tag,
"CAA", "my.site", "letsencrypt.org", 3600L, NA, NA, NA, NA, NA,
"CNAME", "autoconfig", "mailbox.org", 3600L, NA, NA, NA, NA, NA,
"MX", "my.site", "mxext1.mailbox.org", 3600L, NA, NA, NA, NA, NA,
"SRV", "_hkps._tcp.my.site", "pgp.mailbox.org", 3600L, 1L, 1L, 443L, NA, NA,
"TXT", "_mta-sts", "v=STSv1; id=001", 3600L, NA, NA, NA, NA, NA) |>
yay::netlify_dns_records_set(domain = "my.site")
# to use a TOML file that defines a `records` table as input:
pal::toml_read("dns_records.toml")$records |>
purrr::map_dfr(tibble::as_tibble_row) |>
yay::netlify_dns_records_set(domain = "my.site")} # }