Skip to content
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
7 changes: 7 additions & 0 deletions ovh/resource_cloud_project_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ func (r *cloudProjectStorageResource) Read(ctx context.Context, req resource.Rea

endpoint := "/cloud/project/" + url.PathEscape(data.ServiceName.ValueString()) + "/region/" + url.PathEscape(data.RegionName.ValueString()) + "/storage/" + url.PathEscape(data.Name.ValueString()) + "?" + queryParams.Encode()
if err := r.config.OVHClient.Get(endpoint, &responseData); err != nil {
// Handle 404 errors by removing the resource from state
// This allows Terraform to recreate resources deleted outside of Terraform
if errOvh, ok := err.(*ovh.APIError); ok && errOvh.Code == http.StatusNotFound {
tflog.Warn(ctx, fmt.Sprintf("Resource not found, removing from state: %s", endpoint))
resp.State.RemoveResource(ctx)
return
}
resp.Diagnostics.AddError(
fmt.Sprintf("Error calling Get %s", endpoint),
err.Error(),
Expand Down