简体   繁体   中英

How to get ALL the GCP folders from an Organization with `JAVA`?

In my GCP organization which has following hierarchy Org--> folder--> folder--> folder--> projects--> Resources . I need to list folders and check if it has any subfolder and then eventually projects. Is there a way I can get what's down the folder tree(leaf being the folder having projects) given a folder id??

To list the resources that are in a folder you could use the command:

gcloud resource-manager folders list --organization=ORG-ID

Here you could review the documentation with more details about the command:

After that you could search the folder doen the folder you require using the flag --folders with the ID of the folder that you got with the first command you could create a script to automate for this.

Also you could grant the roll as power owner as organization level and use the command:

gcloud beta projects list

this command will list all the projects you could also save it in a file. Using the information of the file you could describe each project to review their parent type and parent ID's.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM