Skip to content

Update the GCP inventory script to avoid sys- projects created by Google AppScript #53

Description

@dataplex

Summary

Google AppScript projects are hosted in GCP projects. These GCP projects are created in the GCP organization. While these can be deleted, and AppScript projects can be redirected to standard GCP projects, it is easier to leave the default configuration.

Depending on how the AppScript is written, a new project can be created every time, leading to many GCP projects being created in the organization. These projects are all created in the system-gsuite/apps-script folder. In all GCP organization, the folder ID for this folder is

Resources

Resolution

Update the script to remove the apps-script folder from the project count. Example:

ORG_ID="$(gcloud organizations list --format=json | jq -r '.[].name' | cut -f2 -d/)"
FOLDERS="$(gcloud resource-manager folders list --organization="${ORG_ID}" --format=json)"
GSUITE_FOLDER_NAME="$(jq -r '.[] | select(.displayName=="system-gsuite") | .name' <<< $FOLDERS)"
GSUITE_FOLDER_ID="$(cut -f2 -d/ <<< $GSUITE_FOLDER_NAME)"

Now query the projects in the GCP organization and filter out the gsuite projects

gcloud projects list --filter="parent.id!=${GSUITE_FOLDER_ID)" --format=json

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions