Skip to content

Get Programatic Access to Oracle Buckets from servers #135

@andrew-e

Description

@andrew-e

Get 'Instance Principals' working and autmomatically set up from the oracle servers to access other oracle things (like the bucket)

import oci

# This tells the SDK to look at the instance metadata for credentials
signer = oci.auth.signers.InstancePrincipalsSecurityTokenSigner()

# Initialize the Object Storage Client
object_storage_client = oci.object_storage.ObjectStorageClient(config={}, signer=signer)

# Get the Namespace (needed for most operations)
namespace = object_storage_client.get_namespace().data

# Example: List objects in your bucket
bucket_name = "YourBucketName"
objects = object_storage_client.list_objects(namespace, bucket_name)

for obj in objects.data.objects:
    print(f"Found file: {obj.name}")

and for the OCI CLI

Sys.setenv(OCI_CLI_AUTH = "instance_principal")
system("oci os object list --bucket-name YourBucketName")

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions