Skip to content

Conversation

@fabiencastarede
Copy link
Contributor

Description

Adds proper 404 error handling to the ovh_cloud_project_storage resource's Read function.

Problem

When a cloud project storage bucket does not exist, or is deleted outside of Terraform (e.g., manually via the OVH console or API), the Terraform provider fails with an error (OVHcloud API error (status code 404): Client::NotFound) instead of gracefully removing the resource from state and allowing Terraform to recreate it.

Changes

  • Add 404 error detection in the Read() function
  • Call resp.State.RemoveResource(ctx) when a 404 is encountered
  • Add a warning log message when removing a missing resource from state
  • Add missing "github.com/ovh/go-ovh/ovh" and "net/http" imports

Benefits

  • Follows Terraform Plugin Framework best practices for handling deleted resources
  • Allows Terraform to automatically recreate resources that were deleted externally
  • Improves user experience by handling drift gracefully
  • Consistent with how other Terraform providers handle missing resources

Testing

Tested by:

  1. Creating a storage bucket with Terraform
  2. Manually deleting it via OVH API
  3. Running terraform refresh - resource cleanly removed from state
  4. Running terraform apply - resource recreated successfully

- Add proper 404 error handling in Read function
- Call resp.State.RemoveResource(ctx) when resource not found
- Allows Terraform to recreate resources deleted outside of Terraform
- Follows Plugin Framework best practices

Signed-off-by: Fabien Castarède <fcastarede@waadoo.cloud>
@jrm-d jrm-d merged commit f6e808c into ovh:master Dec 8, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants