Skip to content
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

Successfully allow changing of set_identifier on route53_record (no more entries dropped from state!) #25620

Merged
merged 6 commits into from
Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
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