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")
Get 'Instance Principals' working and autmomatically set up from the oracle servers to access other oracle things (like the bucket)
and for the OCI CLI