From 8fb18592d32d236238966495b65cb378a24f4dff Mon Sep 17 00:00:00 2001 From: Wayne Cierkowski Date: Mon, 22 Apr 2024 12:37:40 -0400 Subject: [PATCH] IE-3315: Added filter to project query --- tools/c7n_org/scripts/gcpprojects.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/c7n_org/scripts/gcpprojects.py b/tools/c7n_org/scripts/gcpprojects.py index 4baefa453b1..ab50ee7bdbc 100644 --- a/tools/c7n_org/scripts/gcpprojects.py +++ b/tools/c7n_org/scripts/gcpprojects.py @@ -23,14 +23,12 @@ def main(output, exclude, buid, appscript): """ client = Session().client('cloudresourcemanager', 'v1', 'projects') + query_params = {'filter': f"parent.type:folder parent.id:{buid}"} if buid else {} results = [] - for page in client.execute_paged_query('list', {}): + for page in client.execute_paged_query('list', query_params): for project in page.get('projects', []): - if buid and project["parent"]["id"] != buid: - continue - # Exclude App Script GCP Projects if appscript == False: if 'sys-' in project['projectId']: