pkaramol
pkaramol

Reputation: 19432

List Google Cloud resources sorted by time

I am listing my compute disks as follows:

▶ gcloud compute disks list
NAME                                                             LOCATION    LOCATION_SCOPE  SIZE_GB  TYPE         STATUS
foobar                                                           us-east4-b  zone            50       pd-standard  READY
jenkins-kos-pd                                                   us-east4-b  zone            100      pd-standard  READY

I want to list them by creation time. I was unable to find such an option and running

gcloud compute disks list --format="value(name)" --sort-by=TIME --limit=1

yields unpredictable results

Upvotes: 2

Views: 3284

Answers (1)

norbjd
norbjd

Reputation: 11287

You can use creationTimestamp as a sort parameter :

gcloud compute disks list \
    --format="value(name,creationTimestamp)" \
    --sort-by=creationTimestamp

Note that you can sort them by descending order by adding a ~ in front of creationTimestamp :

gcloud compute disks list \
    --format="value(name,creationTimestamp)" \
    --sort-by=~creationTimestamp

Upvotes: 6

Related Questions