<img height="1" width="1" style="display:none;" alt="" src="https://px.ads.linkedin.com/collect/?pid=2634489&amp;fmt=gif">

Google Workspace, Google Cloud Strategy

Bash Script for GCP to fetch data

By Vikash Vikal | November 23, 2021

script to fetch the GCP project details as mention below.

projectid, name, projectnumber, date&time, folderpath, projectowner, folderpath, costcentre, label.

I have written belwo script and it is working for- projectid, name, projectnumber, date&time.

#!/bin/bash

> project_data.csv

gcloud projects list --format="value(project_id, name, project_number, project_owner, tag, createTime.date(tz=LOCAL))" >whole_project_details.txt

echo project_id, project_name, project_number, project_owner, project_tag, project_time >project_data.csv

while read project_details

do

project_id=`echo $project_details | awk '{print $1}'`

project_name=`echo  $project_details | awk '{print $2}'`

project_number=`echo $project_details | awk '{print $3}'`

project_time=`echo $project_details | awk '{print $4}'`

project_owner=`echo $project_details | awk '{print $5}'`

project_tag=`echo $project_details | awk '{print $6}'`

echo $project_id, $project_name, $project_number, $project_owner, $project_tag, $project_time  >> project_data.csv

done < whole_project_details.txt

 

But not able to fetch date of - owner, folderpath, label, costcentre.

 

please help me. Thank you in advance.

 

Best Answer from: sathyaram_s 


 

From the documentation : 

 

To refer to a list of fields you can sort, filter, and format by for each resource, you can run a list command with the format set to text or json. For example, $ gcloud compute instances list --limit=1 --format=text.

 

In your case, try gcloud projects list --format=text to confirm all the information you are after is available for the project resource. 


Recent Articles

Google Cloud Strategy

AI Cheat Sheet

AI is no more and no less the drive to create robots with human minds so they can do everything we do and more. Use this cheat sheet to help decode the space.
By Leah Zitter
AI and Machine Learning

CarCast with Bruno Aziza: What Makes Us Better Than AI?!

Unlock the secrets of human cognitive superiority over AI in this compelling CarCast with Bruno Aziza and Kenneth Cukier.
By Bruno Aziza
AI and Machine Learning

CarCast with Bruno Aziza: The Metrics You CAN'T Afford To ...

Discover essential CEO metrics: Rule of 40, CAC Ratio, NRR/GRR, and more. Optimize your business for success now!
By Bruno Aziza