Skip to content

Commit

Permalink
Add allow_overwrite to dns_records
Browse files Browse the repository at this point in the history
  • Loading branch information
foxdalas committed May 12, 2022
1 parent 7d9187b commit f351cb0
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions dme/resource_dme_dns_records.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ func resourceManagedDNSRecordActions() *schema.Resource {
Optional: true,
Computed: true,
},

"allow_overwrite": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -227,8 +233,19 @@ func resourceManagedDNSRecordActionsCreate(d *schema.ResourceData, m interface{}
cont, err := dmeClient.Save(&recordAttr, "dns/managed/"+d.Get("domain_id").(string)+"/records/")

if err != nil {
log.Println("Error returned: ", err)
return err
if strings.Contains(err.Error(), "already exists") {
if d.Get("allow_overwrite").(bool) {
log.Printf("[DEBUG] DNS Record already exists however we are overwriting it")
cont, err = dmeClient.Update(&recordAttr, "dns/managed/"+d.Get("domain_id").(string)+"/records/")
if err != nil {
log.Println("Error returned: ", err)
return err
}
}
} else {
log.Println("Error returned: ", err)
return err
}
}

log.Println("Value of container: ", cont)
Expand Down

0 comments on commit f351cb0

Please sign in to comment.