'GCP API for getting list of labels
Is there an GCP API for getting labels for resources? I want to get a list of all labels for GCP Project. How to get all labels in GCP? Basically GCP Resource Manager API return the Lebel object for every resource. But I want to get list of all labels using one API call.
Solution 1:[1]
Currently it's not possible to list all labels within a GCP project.
Beside what you mention about GCP Resource Manager API
, you could get some information from Asset Inventory, however it won't fulfill your requirements.
To achieve what you want, you can fill a Feature Request
in GCP IssueTracker to create this possibility.
Solution 2:[2]
I tried the next workaround to get all the labels:
gcloud projects describe <YOUR-PROJECT-NAME> --format=json | jq -r '.labels|to_entries|map("\(.key)=\(.value|tostring)")|.[]'
You will receive a key=value list.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | PjoterS |
Solution 2 | Bumeranghc |