Get bucket metadata (original) (raw)

This page shows you how get information on the metadata of your Cloud Storage buckets, excluding IAM policies and ACLs.

In order to get the required permissions for getting the metadata of a Cloud Storage bucket, ask your administrator to grant you the Storage Admin (roles/storage.admin) role on the bucket.

This role contains the permissions required to get the metadata of a bucket. To see the exact permissions that are required, expand theRequired permissions section:

Console

  1. In the Google Cloud console, go to the Cloud Storage Buckets page.
    Go to Buckets
  2. In the bucket list, click the name of the bucket whose metadata you want to view.
  3. Click the Configuration tab to view bucket details such as the included regions, storage class, permissions, and replication type.

Command line

Use the gcloud storage buckets describe command:

gcloud storage buckets describe gs://BUCKET_NAME

Where:

If successful, the response looks similar to the following example:

defaultEventBasedHold: false etag: CAE= iamConfiguration: bucketPolicyOnly: enabled: true ...

Client libraries

Terraform

You can use a Terraform resource to view a bucket's metadata.

REST APIs

JSON API

  1. Have gcloud CLI installed and initialized, which lets you generate an access token for the Authorization header.
  2. Use cURL to call the JSON APIwith a GET Bucket request:
    curl -X GET \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    "https://storage.googleapis.com/storage/v1/b/BUCKET_NAME"
    Where BUCKET_NAME is the name of the relevant bucket. For example, my-bucket.
    Optionally, you can narrow down the metadata results by using thefields query string parameter. For example:
    curl -X GET \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    "https://storage.googleapis.com/storage/v1/b/BUCKET_NAME?fields=FIELD1%2CFIELD2"
    Where FIELD# is a bucket property you want to include in the result. For example, projectNumber andstorageClass.

The response looks like the following example:

{ "projectNumber": "123456789012", "storageClass": "STANDARD" }

XML API

  1. Have gcloud CLI installed and initialized, which lets you generate an access token for the Authorization header.
  2. Use cURL to call the XML API with aGET Bucket request:
    curl -X GET \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    "https://storage.googleapis.com/BUCKET_NAME?QUERY_PARAMETER"
    Where:
    • BUCKET_NAME is the name of the relevant bucket. For example, my-bucket.
    • QUERY_PARAMETER is the metadata field you want to return. For example, storageClass for getting the bucket's storage class. You can only use one query parameter at a time with the XML API. For a list of metadata fields supported by the XML API, see the GET Bucket reference page.
      The response looks like the following example:<StorageClass>STANDARD</StorageClass>.