Oracle Cloud Infrastructure (OCI) Object Storage provides highly scalable and durable cloud storage for storing unstructured data such as:
- Database backups
- Application files
- Terraform state files
- Logs
- Images and videos
- Archive files
Using OCI CLI, administrators can quickly list all available buckets directly from the terminal.
OCI CLI Command to List Buckets
The following command lists all Object Storage buckets inside a compartment:
oci os bucket list \ --compartment-id <compartment_ocid> \ --namespace <namespace>
Real Example
(base) karandodwal@Karans-MacBook-Air oci % oci os bucket list \ --compartment-id ocid1.tenancy.oc1..aaaaaaaa3vnisivl47yhbkewows6ga6xawrhmg2p37nzqj656rz4j7wt55gq \ --namespace bmsabuehgvp5
Understanding the Command
| Parameter | Description |
|---|---|
| oci | OCI CLI executable |
| os | Object Storage service |
| bucket | Bucket resource type |
| list | Action to display buckets |
| --compartment-id | OCI compartment or tenancy OCID |
| --namespace | Object Storage namespace |
Sample Output
{
"data": [
{
"bucket-scope": "NAMESPACE",
"compartment-id": "ocid1.tenancy.oc1..aaaaaaaa3vnisivl47yhbkewows6ga6xawrhmg2p37nzqj656rz4j7wt55gq",
"created-by": "ocid1.saml2idp.oc1..aaaaaaaagk67dtxfsgsyudgppijtx3gkcipqmoq33o2bh2z55pjryeol4juq/karandodwal@gmail.com",
"etag": "2c6154b3-0051-44fd-82cc-b05d00409442",
"name": "bucket-1031",
"namespace": "bmsabuehgvp5",
"time-created": "2022-06-26T19:07:15.549000+00:00"
}
]
}
Understanding the JSON Output
OCI CLI returns bucket information in JSON format.
The response contains:
"data": [ ]
which is an array of bucket objects.
Important Output Fields Explained
| Field | Description |
|---|---|
| bucket-scope | Defines bucket visibility scope |
| compartment-id | OCI compartment OCID where bucket exists |
| created-by | User or identity that created the bucket |
| etag | Unique identifier used for object version tracking |
| name | Name of the bucket |
| namespace | Object Storage namespace |
| time-created | Bucket creation timestamp |
Understanding the Bucket Name
From the output:
"name": "bucket-1031"
This is the Object Storage bucket name.
The bucket stores objects such as:
- Files
- Backups
- Images
- Application data
Understanding Namespace
The output shows:
"namespace": "bmsabuehgvp5"
A namespace is a unique Object Storage identifier assigned to an OCI tenancy.
All buckets exist inside a namespace.
How to Get Namespace
oci os ns get
Example output:
{
"data": "bmsabuehgvp5"
}
Understanding Bucket Scope
The output shows:
"bucket-scope": "NAMESPACE"
This means the bucket exists within the tenancy namespace.
Understanding the Created-By Field
Example:
"created-by": "ocid1.saml2idp.oc1.../karandodwal@gmail.com"
This indicates:
- The bucket creator identity
- The user or federated identity used
- Audit tracking information
Understanding the ETag
Example:
"etag": "2c6154b3-0051-44fd-82cc-b05d00409442"
ETag is used internally by OCI for:
- Object version tracking
- Concurrency control
- API request validation
Understanding Time-Created
Example:
"time-created": "2022-06-26T19:07:15.549000+00:00"
This indicates when the bucket was created in UTC format.
What About the Warning Message?
The command output also displayed:
FutureWarning: The 'strict' parameter is no longer needed on Python 3+
Why Does This Warning Appear?
This is a Python library compatibility warning from:
urllib3
It usually appears because:
- OCI CLI uses Python internally
- Python 3.14 introduced changes
- Some older library parameters are deprecated
This warning does not usually affect bucket operations.
Display Bucket List in Table Format
JSON output is useful for automation, but table output is easier to read.
Example
oci os bucket list \ --compartment-id <compartment_ocid> \ --namespace <namespace> \ --output table
Filter Bucket Output Using Queries
Display Only Bucket Names
oci os bucket list \ --compartment-id <compartment_ocid> \ --namespace <namespace> \ --query "data[*].name"
Display Only Creation Time
oci os bucket list \ --compartment-id <compartment_ocid> \ --namespace <namespace> \ --query "data[*].time-created"
Useful Related Bucket Commands
Get Bucket Details
oci os bucket get \ --bucket-name bucket-1031 \ --namespace bmsabuehgvp5
List Objects Inside Bucket
oci os object list \ --bucket-name bucket-1031
Upload File to Bucket
oci os object put \ --bucket-name bucket-1031 \ --file backup.zip
OCI Object Storage Use Cases
- RMAN backups
- Database exports
- Terraform remote state
- Log archival
- Application storage
- Static website hosting
- Data lake storage
OCI CLI Benefits
- Automation friendly
- Supports scripting
- Useful for DevOps pipelines
- Faster than manual console operations
- Supports Infrastructure as Code workflows
Conclusion
The OCI CLI command:
oci os bucket list
is one of the most commonly used Object Storage operations in Oracle Cloud Infrastructure.
It helps administrators:
- Discover available buckets
- Verify storage configuration
- Manage Object Storage resources
- Automate cloud storage operations
Combined with Object Storage APIs, Cloud Shell, and automation tools, OCI CLI provides a powerful way to manage enterprise cloud storage directly from the terminal.
No comments:
Post a Comment