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

fix(rdb): migrate endpoint to endpoints #2728

Merged
merged 3 commits into from
Sep 9, 2024
Merged
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
23 changes: 19 additions & 4 deletions internal/services/rdb/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,10 +460,25 @@ func ResourceRdbInstanceRead(ctx context.Context, d *schema.ResourceData, m inte
_ = d.Set("backup_same_region", res.BackupSameRegion)
_ = d.Set("tags", types.FlattenSliceString(res.Tags))

// Deprecated attribute, might be deleted later
if res.Endpoint != nil { //nolint:staticcheck
_ = d.Set("endpoint_ip", types.FlattenIPPtr(res.Endpoint.IP)) //nolint:staticcheck
_ = d.Set("endpoint_port", int(res.Endpoint.Port)) //nolint:staticcheck
var loadBalancerEndpoint *rdb.Endpoint

for _, endpoint := range res.Endpoints {
if endpoint.LoadBalancer != nil {
loadBalancerEndpoint = endpoint
break
}
}

if loadBalancerEndpoint != nil {
switch {
case loadBalancerEndpoint.IP != nil:
_ = d.Set("endpoint_ip", types.FlattenIPPtr(loadBalancerEndpoint.IP))
case loadBalancerEndpoint.Hostname != nil:
_ = d.Set("endpoint_ip", loadBalancerEndpoint.Hostname)
default:
_ = d.Set("endpoint_ip", "")
}
_ = d.Set("endpoint_port", int(loadBalancerEndpoint.Port))
} else {
_ = d.Set("endpoint_ip", "")
_ = d.Set("endpoint_port", 0)
Expand Down
Loading