From 42e901fce45ede963c1bdaff6e306f7ad2aa26a4 Mon Sep 17 00:00:00 2001 From: Vincent Roseberry Date: Tue, 1 Aug 2017 09:59:27 -0700 Subject: [PATCH] Improve docs for `dns_record_set` by adding example for SPF record. (#266) --- website/docs/r/dns_record_set.markdown | 32 +++++++++++++++++++++----- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/website/docs/r/dns_record_set.markdown b/website/docs/r/dns_record_set.markdown index dcf33371..90d93591 100644 --- a/website/docs/r/dns_record_set.markdown +++ b/website/docs/r/dns_record_set.markdown @@ -12,9 +12,19 @@ Manages a set of DNS records within Google Cloud DNS. ## Example Usage -This example is the common case of binding a DNS name to the ephemeral IP of a new instance: +### Binding a DNS name to the ephemeral IP of a new instance: ```hcl +resource "google_dns_record_set" "frontend" { + name = "frontend.${google_dns_managed_zone.prod.dns_name}" + type = "A" + ttl = 300 + + managed_zone = "${google_dns_managed_zone.prod.name}" + + rrdatas = ["${google_compute_instance.frontend.network_interface.0.access_config.0.assigned_nat_ip}"] +} + resource "google_compute_instance" "frontend" { name = "frontend" machine_type = "g1-small" @@ -34,15 +44,25 @@ resource "google_dns_managed_zone" "prod" { name = "prod-zone" dns_name = "prod.mydomain.com." } +``` -resource "google_dns_record_set" "frontend" { +### Adding a SPF record + +`\"` must be added around your `rrdatas` for a SPF record. Otherwise `rrdatas` string gets split on spaces. + +```hcl +resource "google_dns_record_set" "spf" { name = "frontend.${google_dns_managed_zone.prod.dns_name}" - type = "A" + managed_zone = "${google_dns_managed_zone.prod.name}" + type = "TXT" ttl = 300 - managed_zone = "${google_dns_managed_zone.prod.name}" + rrdatas = ["\"v=spf1 ip4:111.111.111.111 include:backoff.email-example.com -all\""] +} - rrdatas = ["${google_compute_instance.frontend.network_interface.0.access_config.0.assigned_nat_ip}"] +resource "google_dns_managed_zone" "prod" { + name = "prod-zone" + dns_name = "prod.mydomain.com." } ``` @@ -56,7 +76,7 @@ The following arguments are supported: * `name` - (Required) The DNS name this record set will apply to. * `rrdatas` - (Required) The string data for the records in this record set - whose meaning depends on the DNS type. + whose meaning depends on the DNS type. For TXT record, if the string data contains spaces, add surrounding `\"` if you don't want your string to get split on spaces. * `ttl` - (Required) The time-to-live of this record set (seconds).