Skip to content

Conversation

@fabiencastarede
Copy link
Contributor

Description

Adds custom external name configuration for the ovh_cloud_project_storage resource to support the patched OVH Terraform provider that properly populates the ID field.

Problem

The ovh_cloud_project_storage resource requires custom external name configuration because:

  1. The OVH Terraform provider is being updated to populate the ID field with composite format: service_name/region_name/name
  2. The external name (Kubernetes resource name) should only be the bucket name
  3. Import operations require the full composite ID format

Without this configuration, the resource cannot:

  • Extract the correct external name from Terraform state
  • Construct proper import IDs for existing resources
  • Map between Crossplane and Terraform naming correctly

Changes

config/external_name.go

  • Add storageIdentifierFromProvider configuration with:
  • GetExternalNameFn: Parses composite ID and extracts bucket name (last component)
  • GetIDFn: Constructs composite import ID from parameters (service_name/region_name/name)
  • Input validation for ID format
  • Add ovh_cloud_project_storage to ExternalNameConfigs map

config/cloud/config.go

  • Add resource configurator to set ShortGroup = "cloud" for storage resource
  • Enables proper resource organization

How It Works

During resource creation:

  1. User creates ProjectRegionStorage with metadata.name: my-bucket
  2. Terraform creates bucket, provider sets ID to service123/GRA/my-bucket
  3. GetExternalNameFn extracts my-bucket as external name

During import:

  1. User specifies external name: my-bucket with parameters
  2. GetIDFn constructs import ID: service123/GRA/my-bucket
  3. Terraform imports using composite ID format
  4. GetExternalNameFn extracts bucket name for Crossplane

Depends On

This configuration works with the patched OVH Terraform provider pending PRs at https://github.com/ovh/terraform-provider-ovh:

Until those PRs are merged, users can use a locally patched provider via filesystem mirror.

Testing

Tested with patched provider (v2.9.0):

  • ✅ Resource creation
  • ✅ Resource updates
  • ✅ Resource deletion
  • ✅ Import existing resources
  • ✅ Drift detection and reconciliation

Example Usage

apiVersion: cloud.ovh.upbound.io/v1alpha1
kind: ProjectRegionStorage
metadata:
name: my-bucket
spec:
forProvider:
  serviceName: "my-service-id"
  regionName: GRA
providerConfigRef:
  name: default

Results in:
- Terraform ID: my-service-id/GRA/my-bucket
- External name: my-bucket
- Import ID: my-service-id/GRA/my-bucket

…rage

This commit adds proper configuration for the ovh_cloud_project_storage
resource to handle its composite ID format (service_name/region_name/name).

Changes:
- Added storageIdentifierFromProvider in config/external_name.go
  - GetExternalNameFn: Extracts bucket name from composite ID
  - GetIDFn: Reconstructs full ID for import operations
- Updated ExternalNameConfigs to use storageIdentifierFromProvider
- Added resource configurators in cluster and namespaced cloud configs
  - Sets shortGroup to "cloud" for both scopes
  - Allows upjet to auto-generate Kind value

This configuration enables proper import, create, update, and delete
operations for object storage containers in OVH Cloud.
@fabiencastarede fabiencastarede force-pushed the fix/storage-config-minimal branch from a52c03d to 295fdf0 Compare December 9, 2025 21:09
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.

1 participant