Skip to content

Fix google_dns_record_set with same name throw an error #11622

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

Merged
merged 4 commits into from
Sep 9, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions mmv1/third_party/terraform/services/dns/resource_dns_record_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,27 +354,6 @@ func resourceDnsRecordSetCreate(d *schema.ResourceData, meta interface{}) error
Additions: []*dns.ResourceRecordSet{rset},
}

// The terraform provider is authoritative, so what we do here is check if
// any records that we are trying to create already exist and make sure we
// delete them, before adding in the changes requested. Normally this would
// result in an AlreadyExistsError.
log.Printf("[DEBUG] DNS record list request for %q", zone)
res, err := config.NewDnsClient(userAgent).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 != rType || record.Name != name {
continue
}
deletions = append(deletions, record)
}
if len(deletions) > 0 {
chg.Deletions = deletions
}

log.Printf("[DEBUG] DNS Record create request: %#v", chg)
chg, err = config.NewDnsClient(userAgent).Changes.Create(project, zone, chg).Do()
if err != nil {
Expand Down
Loading