This is an automated email from the ASF dual-hosted git repository.
sureshanaparti pushed a commit to branch main
in repository
https://gitbox.apache.org/repos/asf/cloudstack-terraform-provider.git
The following commit(s) were added to refs/heads/main by this push:
new b166fdf Allow admin accounts to import projects by setting
listall=true in project lookup (#324)
b166fdf is described below
commit b166fdf79fbb30e857a487cc00d31a64d0f7a7c6
Author: Suresh Kumar Anaparti <[email protected]>
AuthorDate: Mon Aug 17 22:14:12 2026 +0530
Allow admin accounts to import projects by setting listall=true in project
lookup (#324)
When an admin account that is not a member of a project tries to import it,
the project lookup fails because listall is not set. The CloudStack API
defaults to listall=false which only returns projects the account owns or is
a member of, regardless of the caller's role.
Setting listall=true in the getProjectByID helper allows admins (Root Admin
or Domain Admin) to see and import projects they have authority over, even
if they are not members. This does not widen privileges as the management
server still enforces role and domain-subtree entitlements.
Fixes: #303
---
cloudstack/resource_cloudstack_project.go | 1 +
1 file changed, 1 insertion(+)
diff --git a/cloudstack/resource_cloudstack_project.go
b/cloudstack/resource_cloudstack_project.go
index ce113e4..9c02846 100644
--- a/cloudstack/resource_cloudstack_project.go
+++ b/cloudstack/resource_cloudstack_project.go
@@ -181,6 +181,7 @@ func resourceCloudStackProjectCreate(d
*schema.ResourceData, meta any) error {
func getProjectByID(cs *cloudstack.CloudStackClient, id string, domain
...string) (*cloudstack.Project, error) {
p := cs.Project.NewListProjectsParams()
p.SetId(id)
+ p.SetListall(true)
// If domain is provided, use it to narrow the search
if len(domain) > 0 && domain[0] != "" {