Skip to content

fix(mongodb): delete pn during delete for fix test #3034

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

Closed
wants to merge 9 commits into from
21 changes: 20 additions & 1 deletion internal/services/mongodb/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,26 @@ func ResourceInstanceDelete(ctx context.Context, d *schema.ResourceData, m inter
return diag.FromErr(err)
}

instance, err := waitForInstance(ctx, mongodbAPI, region, ID, d.Timeout(schema.TimeoutDelete))
if err != nil {
return diag.FromErr(err)
}

for _, endpoint := range instance.Endpoints {
if endpoint.PrivateNetwork != nil {
err := mongodbAPI.DeleteEndpoint(
&mongodb.DeleteEndpointRequest{
EndpointID: endpoint.ID,
Region: region,
},
scw.WithContext(ctx),
)
if err != nil {
return diag.FromErr(err)
}
}
}

_, err = waitForInstance(ctx, mongodbAPI, region, ID, d.Timeout(schema.TimeoutDelete))
if err != nil {
return diag.FromErr(err)
Expand All @@ -569,6 +589,5 @@ func ResourceInstanceDelete(ctx context.Context, d *schema.ResourceData, m inter
}

d.SetId("")

return nil
}
Loading
Loading