Cluster Sharing Best Practices with the Rafay Terraform Provider¶
This document outlines recommended practices for configuring and managing cluster sharing across projects using the Rafay Terraform Provider. It also highlights important enforcement changes introduced in provider version v1.1.47, which aim to eliminate misconfigurations and ensure consistency.
In Rafay, clusters can be shared across projects to enable broader access. Terraform offers multiple ways to define this sharing, but only one method should be used at a time to avoid configuration drift or errors.
To ensure long-term maintainability and safe Day-2 operations (e.g., adding or removing projects from shared access), Rafay recommends using external sharing resources instead of embedding sharing within the cluster resource.
Use the following resources:
rafay_cluster_sharing – When sharing a cluster with multiple projects.
rafay_cluster_sharing_single – When sharing a cluster with exactly one project.
Why?
Keeping sharing logic separate from the cluster spec helps decouple cluster lifecycle operations from access management and reduces the risk of accidental cluster modifications.
Starting with provider version v1.1.47, you can no longer use multiple sharing mechanisms for the same cluster in a single configuration.
If you mix embedded sharing and external sharing resources, Terraform plan/apply will fail with an error.
Detected conflicting cluster sharing configurations in both 'rafay_*_cluster' and 'rafay_cluster_sharing' resources.
Please consolidate the sharing settings into a single resource.
2. Adding Embedded Sharing After External Sharing Exists¶
If the cluster is already shared using rafay_cluster_sharing, adding an embedded sharing block will raise a similar error.
If someone manually updates cluster sharing using the UI or API, Terraform will detect a drift on the next plan:
Example:
Cluster is shared with project-a and project-b via embedded block,
A third project project-c is added via the UI.
→ terraform plan will show that project-c is not part of the config and should be removed.
Another case:
One of the shared projects is removed via the UI.
→ terraform plan will detect the drift and show it needs to be re-added to match Terraform state.
To avoid such conflicts, always manage cluster sharing exclusively through Terraform once it's being used.