Chapter 3. Listing available buckets in your object store


To list buckets that are available in your object store, use the list_bucket() method.

Prerequisites

  • You have cloned the odh-doc-examples repository to your workbench.
  • You have opened the s3client_examples.ipynb file in your workbench.
  • You have installed Boto3 and configured the S3 client.

Procedure

  1. In the Jupyter notebook, locate the following instructions that lists available buckets and then run the code cell.

    #List available buckets
    s3_client.list_buckets()
    Copy to Clipboard

    A successful response includes an HTTP request status code of 200 and a list of buckets, similar to the following output:

    'HTTPStatusCode': 200,
    'Buckets': [{'Name': 'aqs086-image-registry',
    'CreationDate': datetime.datetime(2024, 1, 16, 20, 21, 36, 244000, tzinfo=tzlocal( ))},
    Copy to Clipboard
  2. Locate the instructions that prints only the names of available buckets and execute the code cell.

    #Print only names of available buckets
    for bucket in s3_client.list_buckets()[‘Buckets’]:
        print(bucket[‘Name’])
    Copy to Clipboard

    The output displays the names of the buckets, similar to the following example.

    aqs086-image-registry
    aqs087-image-registry
    aqs135-image-registry
    aqs246-image-registry
    Copy to Clipboard
Back to top
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2025 Red Hat