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
Closed
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions internal/services/container/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
containerchecks "github.com/scaleway/terraform-provider-scaleway/v2/internal/services/container/testfuncs"
)


func TestAccContainer_Basic(t *testing.T) {
tt := acctest.NewTestTools(t)
defer tt.Cleanup()
Expand Down
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