Skip to content

Commit

Permalink
Merge pull request #25620 from handlerbot/b-route53_record-set_identi…
Browse files Browse the repository at this point in the history
…fier-change-issue7998

Successfully allow changing of set_identifier on route53_record (no more entries dropped from state!)
  • Loading branch information
ewbankkit authored Jun 30, 2022
2 parents c02f4d5 + d5d97fc commit 02a62a8
Show file tree
Hide file tree
Showing 3 changed files with 475 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .changelog/25620.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_route53_record: Successfully allow renaming of `set_identifier` (specified with multiple routing policies)
```
48 changes: 46 additions & 2 deletions internal/service/route53/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,52 @@ func resourceRecordUpdate(d *schema.ResourceData, meta interface{}) error {
Type: aws.String(typeo.(string)),
}

// If the old record had a weighted_routing_policy we need to pass that in
// here because otherwise the API will give us an error.
// If the old record has any of the following, we need to pass that in
// here because otherwise the API will give us an error:
// - failover_routing_policy
// - geolocation_routing_policy
// - latency_routing_policy
// - multivalue_answer_routing_policy
// - weighted_routing_policy

if v, _ := d.GetChange("failover_routing_policy"); v != nil {
if o, ok := v.([]interface{}); ok {
if len(o) == 1 {
if v, ok := o[0].(map[string]interface{}); ok {
oldRec.Failover = aws.String(v["type"].(string))
}
}
}
}

if v, _ := d.GetChange("geolocation_routing_policy"); v != nil {
if o, ok := v.([]interface{}); ok {
if len(o) == 1 {
if v, ok := o[0].(map[string]interface{}); ok {
oldRec.GeoLocation = &route53.GeoLocation{
ContinentCode: nilString(v["continent"].(string)),
CountryCode: nilString(v["country"].(string)),
SubdivisionCode: nilString(v["subdivision"].(string)),
}
}
}
}
}

if v, _ := d.GetChange("latency_routing_policy"); v != nil {
if o, ok := v.([]interface{}); ok {
if len(o) == 1 {
if v, ok := o[0].(map[string]interface{}); ok {
oldRec.Region = aws.String(v["region"].(string))
}
}
}
}

if v, _ := d.GetChange("multivalue_answer_routing_policy"); v != nil && v.(bool) {
oldRec.MultiValueAnswer = aws.Bool(v.(bool))
}

if v, _ := d.GetChange("weighted_routing_policy"); v != nil {
if o, ok := v.([]interface{}); ok {
if len(o) == 1 {
Expand Down
Loading

0 comments on commit 02a62a8

Please sign in to comment.