Search code examples
google-cloud-sdk

Google's cloud SDK doesn't return `createTime`


I'm trying to list info about some instances using cloud sdk, but for some reason the createTime field is not returned. Any idea why?

$ gcloud compute instances list --format="table(name,createTime)" --filter="name:florin*"
NAME                         CREATE_TIME
florin-ubuntu-18-playground

This should work according to this https://cloud.google.com/sdk/gcloud/reference/topic/filters


Solution

  • The command gcloud compute instances list does not show the instances creation time by default. But the gcloud --format flag can change the default output displayed.

    gcloud compute instances list --format="table(name,creationTimestamp)"

    It is also possible to retrieve the instance creation time from the gcloud compute describe command:

    gcloud compute instances describe yourInstance --zone=yourInstanceZone | grep creationTimestamp
    

    Or:

    gcloud compute instances describe yourInstance --zone=yourInstanceZone --flatten=creationTimestamp