Get bucket metadata

Concepts

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

To learn how to get the IAM policy of your bucket, see View the IAM policy for a bucket .

Required roles

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 the Required permissionssection:

Required permissions

  • storage.buckets.get
  • storage.buckets.list
    • This permission is only needed if you plan on using the Google Cloud console to perform the task on this page.

You might also be able to get these permissions with other predefined roles or custom roles .

For instructions on granting roles on buckets, see Use IAM with buckets .

Display a bucket's metadata

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 Configurationtab 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:

  • BUCKET_NAME is the name of the bucket whose metadata you want to view. For example, my-awesome-bucket .

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.

 # Get bucket metadata
data "google_storage_bucket" "default" {
  name = google_storage_bucket.static.id
}

output "bucket_metadata" {
  value = data.google_storage_bucket.default
} 

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 API with 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 the fields 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 
    %2C FIELD2 
    "

    Where FIELD# is a bucket property you want to include in the result. For example, projectNumber and storageClass .

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 a GET 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> .

What's next

Try it for yourself

If you're new to Google Cloud, create an account to evaluate how Cloud Storage performs in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.

Try Cloud Storage free
Design a Mobile Site
View Site in Mobile | Classic
Share by: