File tree Expand file tree Collapse file tree 3 files changed +78
-4
lines changed
examples/organization-org_compliance Expand file tree Collapse file tree 3 files changed +78
-4
lines changed Original file line number Diff line number Diff line change @@ -152,8 +152,14 @@ output "me" {
152152```
153153
154154### Q: In organizaitonal setup, Compliance trust-relationship is not being deployed on our projects
155- A: If your organizational uses folders we currently don' t support that.
156- < br/> S: A workaround would be to use the ` benchmark_project_ids` parameter so you can define the projects where compliance role is to be deployed explicitly. Let us know if this workaround won' t be enough and we will work on implementing a solution.
155+
156+ As for 2023 April, organizations with projects under organizational unit folders, is supported with the
157+ [organizational compliance example](./examples/organization-org_compliance)
158+
159+ <br/>S: If you want to target specific projects, you can still use the `benchmark_project_ids` parameter so you can define
160+ the projects where compliance role is to be deployed explicitly.
161+ <br/>You can use the [fetch-gcp-rojects.sh](./resources/fetch-gcp-projects.sh) utility to list organization member projects
162+ <br/>Let us know if this workaround won' t be enough, and we will work on implementing a solution.
157163
158164# ## Q: Compliance is not working. How can I check everything is properly setup
159165
Original file line number Diff line number Diff line change @@ -16,10 +16,16 @@ This example deploys Secure for Cloud into a GCP organizational account.
1616## Prerequisites
1717
18181 . Configure [ Terraform ** GCP** Provider] ( https://registry.terraform.io/providers/hashicorp/google/latest/docs )
19- 2 . Following ** roles** are required in your GCP organization/project credentials
19+ 2 . Run the script at ` resources/fetch-gcp-projects.sh <organization_ID> ` . copy the output and provide it as input in the module
20+ as benchmark_project_ids. e.g benchmark_project_ids = [ "id1","id2"] . This script provides list of
21+ all projects under folders and subfolders under an organization. If you don't provide this list
22+ by default only those projects are selected which are directly under the org.
23+ 3 . To find your organization id please visit https://cloud.google.com/resource-manager/reference/rest/v1/projects/getAncestry
24+ 4 . Following ** roles** are required in your GCP organization/project credentials
2025 * _ Owner_
2126 * _ Organization Admin_
22- 3 . Besides, the following GCP ** APIs must be enabled** to deploy resources correctly for:
27+ * _ Organization ID_
28+ 5 . Besides, the following GCP ** APIs must be enabled** to deploy resources correctly for:
2329
2430### Cloud Connector
2531
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ #
4+ # usage
5+ # ./fetch-gcp-projects.sh <ORG-ID>
6+
7+ # will return
8+ # ["A", "B", "C"]
9+ #
10+
11+
12+ #
13+ # Function to list projects under a folder recursively
14+ #
15+ list_projects_recursive () {
16+ local folder_id=" $1 "
17+
18+ # List projects under the current folder
19+ printf " %s" $( gcloud projects list --filter=" parent.id=$folder_id " --format=" value(projectId)" )
20+
21+ # List subfolders and call this function recursively
22+ local subfolders=$( gcloud resource-manager folders list --folder=$folder_id --format=" value(name)" )
23+ for subfolder in $subfolders ; do
24+ list_projects_recursive " $subfolder "
25+ done
26+ }
27+
28+
29+
30+ #
31+ # main flow
32+ #
33+
34+ if [ $# -ne 1 ]; then
35+ echo " script must be launched with the organization id"
36+ echo " usage $0 organizationId"
37+ exit 1
38+ fi
39+
40+
41+ org_id=$1
42+ projectIds=()
43+ projectIds+=$( gcloud projects list --filter=" parent.type=organization AND parent.id=$org_id " --format=" value(projectId)" )
44+
45+ # List top-level folders
46+ folders=$( gcloud resource-manager folders list --organization=$org_id --format=" value(name)" )
47+
48+ # Iterate through the top-level folders and list projects recursively
49+ for folder in $folders ; do
50+ projectIds+=$( list_projects_recursive " $folder " )
51+ done
52+
53+ projectList=" ["
54+
55+ for value in $projectIds ; do
56+ projectList=" $projectList \" $value \" , "
57+ done
58+
59+ # Remove the trailing comma and space
60+ projectList=" ${projectList% , } ]"
61+
62+ echo $projectList
You can’t perform that action at this time.
0 commit comments