Monday, 25 May 2026

Understanding OCI Object Storage Bucket Commands Using OCI CLI

Oracle Cloud Infrastructure (OCI) Object Storage is a highly scalable cloud storage service used to store unstructured data such as:

  • Backups
  • Images
  • Videos
  • Database exports
  • Logs
  • Application files
  • Terraform state files

Using OCI CLI, administrators can manage Object Storage buckets directly from the terminal.


Checking Available Bucket Commands

The following command displays all available bucket operations in OCI CLI:

oci os bucket -h

Example Terminal Output

(base) karandodwal@Karans-MacBook-Air oci % oci os bucket -h
Usage: oci os bucket [OPTIONS] COMMAND [ARGS]...

  A bucket is a container for storing objects in a compartment within a
  namespace. A bucket is associated with a single compartment.

Commands:
  create
  delete
  get
  list
  reencrypt
  update

Understanding OCI Object Storage Buckets

A bucket is a logical container inside OCI Object Storage where objects (files) are stored.

Examples of objects:

  • ZIP files
  • Backups
  • Images
  • JSON files
  • Database dump files
  • Terraform state files

OCI Object Storage Hierarchy

Tenancy
 └── Compartment
      └── Namespace
           └── Bucket
                └── Objects

What the Help Output Explains

The OCI CLI help output provides:

  • Command usage syntax
  • Bucket descriptions
  • Available bucket operations
  • IAM authorization requirements

Basic OCI Bucket Command Structure

oci os bucket <command>

Available Bucket Commands Explained

Command Description
create Create a new bucket
delete Delete an empty bucket
get Display bucket details
list List all buckets in a compartment
reencrypt Re-encrypt bucket encryption keys
update Modify bucket settings

1. Create Bucket

Creates a new Object Storage bucket.

Example

oci os bucket create \
--compartment-id <compartment_ocid> \
--name mybucket \
--namespace-name <namespace>

2. Delete Bucket

Deletes a bucket if it is empty.

Example

oci os bucket delete \
--bucket-name mybucket \
--namespace-name <namespace> \
--force

Important:

  • Bucket must be empty before deletion
  • All objects should be removed first

3. Get Bucket Details

Displays detailed information about a bucket.

Example

oci os bucket get \
--bucket-name mybucket \
--namespace-name <namespace>

4. List Buckets

Lists all buckets inside a compartment.

Example

oci os bucket list \
--compartment-id <compartment_ocid> \
--namespace-name <namespace>

5. Re-encrypt Bucket

The reencrypt command is used to re-encrypt bucket encryption keys.

This is useful when:

  • Rotating encryption keys
  • Improving security compliance
  • Changing KMS configurations

Example

oci os bucket reencrypt \
--bucket-name mybucket \
--namespace-name <namespace>

6. Update Bucket

Updates bucket settings and properties.

Example

oci os bucket update \
--bucket-name mybucket \
--namespace-name <namespace> \
--public-access-type NoPublicAccess

IAM Authorization Requirement

The help output also mentions:

To use any of the API operations, you must be authorized in an IAM policy.

This means OCI users need proper IAM permissions to work with buckets.


Example IAM Policy for Object Storage

Allow group StorageAdmins to manage object-family in compartment Production

Understanding OCI Namespace

Object Storage buckets exist inside a namespace.

A namespace is automatically generated for each OCI tenancy.


Get Namespace

oci os ns get

Example output:

{
  "data": "mytenancynamespace"
}

Useful Related OCI Object Storage Commands

List Objects in a Bucket

oci os object list \
--bucket-name mybucket

Upload Object

oci os object put \
--bucket-name mybucket \
--file backup.zip

Download Object

oci os object get \
--bucket-name mybucket \
--name backup.zip \
--file backup.zip

Display Bucket Commands Help

You can get detailed help for individual bucket commands.

Example

oci os bucket create --help

Display Output in Table Format

OCI CLI supports table formatting for readability.

Example

oci os bucket list \
--compartment-id <compartment_ocid> \
--namespace-name <namespace> \
--output table

Why OCI CLI is Useful for Object Storage

  • Automates storage management
  • Useful for scripting
  • Supports backups and restore automation
  • Works well with DevOps pipelines
  • Faster than manual console operations
  • Supports Terraform and Infrastructure as Code

OCI CLI and Cloud Shell

OCI CLI can run from:

  • macOS Terminal
  • Linux servers
  • Windows WSL
  • Oracle Cloud Shell

Oracle Cloud Shell already includes OCI CLI pre-installed and authenticated.


Best Practices for OCI Buckets

  • Use private buckets unless public access is required
  • Enable encryption
  • Use IAM least privilege policies
  • Organize buckets by workload
  • Monitor bucket usage
  • Use lifecycle policies for cost optimization

Conclusion

The command:

oci os bucket -h

is an excellent starting point for learning OCI Object Storage management using OCI CLI.

It provides visibility into all major bucket operations including:

  • Bucket creation
  • Listing buckets
  • Updating bucket settings
  • Deleting buckets
  • Encryption management

OCI Object Storage combined with OCI CLI provides a powerful and automation-friendly cloud storage platform for enterprise workloads and cloud-native applications.

No comments:

Post a Comment