Skip to content

Conversation

@fabiencastarede
Copy link
Contributor

Description

Fixes the ovh_cloud_project_storage resource to properly populate the id field in Terraform state.

Problem

The ovh_cloud_project_storage resource declares an id attribute in its schema but never populates it, leaving it as null in the Terraform state. According to Terraform Plugin Framework
best practices
, if an id attribute is declared in the schema, it should be populated.

This causes issues with:

  • Tools and frameworks that expect a populated ID field in Terraform state
  • Inconsistency with other resources in the provider (e.g., ovh_cloud_project_database properly populates its ID)
  • User expectations when inspecting state files

Changes

  • Add ovhtypes import for TfString type creation
  • Populate ID in Create() function after resource creation
  • Populate ID in Read() function after fetching resource details
  • Populate ID in Update() function after updating resource
  • ID format: service_name/region_name/name (matches the import format defined in ImportState())

Benefits

  • Complies with Plugin Framework best practices
  • Provides consistency across the provider
  • Makes the ID format explicit and matches import expectations
  • Improves tooling compatibility

Testing

Tested with:

  • Resource creation ✅
  • Resource updates ✅
  • Resource deletion ✅
  • Resource import ✅
  • State inspection ✅

The existing acceptance tests continue to pass as they already use the correct import ID format (service_name/region_name/name).

Backward Compatibility

This change is backward compatible since the ID field was previously null. Adding a value doesn't break existing workflows.

The ovh_cloud_project_storage resource declares an 'id' attribute in its
schema but never populates it, leaving it as null in the Terraform state.
According to Terraform Plugin Framework best practices, if an 'id'
attribute is declared in the schema, it should be populated.

This change populates the ID field with a composite key format
"service_name/region_name/name" in the Create, Read, and Update functions.
This format matches the expected import ID format defined in the
ImportState function, providing consistency across operations.

Changes:
- Add ovhtypes import for TfString type creation
- Populate ID in Create function after resource creation
- Populate ID in Read function after fetching resource details
- Populate ID in Update function after updating resource

This fixes issues where the null ID causes problems with tools that
expect a populated ID field in Terraform state, and ensures consistency
with other resources in the provider that properly populate their IDs.

Signed-off-by: Fabien Castarède <[email protected]>
Copy link
Contributor

@jrm-d jrm-d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @fabiencastarede, thanks a lot for your contribution !
My only suggestion would be to update the related ovh/resource_cloud_project_storage_test.go in order to validate that id is populated with the adequate value

Add TestCheckResourceAttr assertions to validate that the ID field
is properly populated with the composite key format (service_name/region_name/name)
in both basic and replication test cases.

This ensures the ID population fix is working correctly across:
- Resource creation
- Resource updates
- Import operations

Signed-off-by: Fabien Castarède <[email protected]>
@jrm-d jrm-d merged commit d007105 into ovh:master Dec 9, 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.

3 participants