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
orjson
. 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.