-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dns: Add special handling for ns records. #359
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,6 +77,25 @@ func resourceDnsRecordSetCreate(d *schema.ResourceData, meta interface{}) error | |
}, | ||
} | ||
|
||
if d.Get("type").(string) == "NS" { | ||
log.Printf("[DEBUG] DNS record list request for %q", zone) | ||
res, err := config.clientDns.ResourceRecordSets.List(project, zone).Do() | ||
if err != nil { | ||
return fmt.Errorf("Error retrieving record sets for %q: %s", zone, err) | ||
} | ||
var deletions []*dns.ResourceRecordSet | ||
|
||
for _, record := range res.Rrsets { | ||
if record.Type != "NS" { | ||
continue | ||
} | ||
deletions = append(deletions, record) | ||
} | ||
if len(deletions) > 0 { | ||
chg.Deletions = deletions | ||
} | ||
} | ||
|
||
log.Printf("[DEBUG] DNS Record create request: %#v", chg) | ||
chg, err = config.clientDns.Changes.Create(project, zone, chg).Do() | ||
if err != nil { | ||
|
@@ -135,6 +154,14 @@ func resourceDnsRecordSetRead(d *schema.ResourceData, meta interface{}) error { | |
} | ||
|
||
func resourceDnsRecordSetDelete(d *schema.ResourceData, meta interface{}) error { | ||
|
||
// NS records must always have a value, so we short-circuit delete | ||
// this allows terraform delete to work, but may have unexpected | ||
// side-effects when deleting just that record set. | ||
if d.Get("type").(string) == "NS" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's put a |
||
log.Println("[DEBUG] NS records can't be deleted due to API restrictions, so they're being left in place. See https://www.terraform.io/docs/providers/google/r/dns_record_set.html for more information.") | ||
return nil | ||
} | ||
config := meta.(*Config) | ||
|
||
project, err := getProject(d, config) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment explaining why this section needs to happen? (even just a link to the docs is probably fine)