1. Create Customer Secret Key from OCI User settings. S3 compatibility key is now called “customer secret key”
Link : https://docs.cloud.oracle.com/en-us/iaas/Content/Identity/Tasks/managingcredentials.htm#Working2
2. Install Python packages –> oci, awscli, boto3 (boto3 is Amazons Python SDK)
3. Add the secret key credentials to a .py file using below code. This will list out your OCI buckets and upload a sample file in /tmp from your local instance(VM) to OCI bucket. In my case the bucket is called “Shadab-DB-Migrate”
import boto3
import oci
config= oci.config.from_file(“~/.oci/config”)
s3 = boto3.resource(
‘s3’,
region_name=”ap-sydney-1″,
aws_secret_access_key=”**************”,
aws_access_key_id=”****************************************”,
endpoint_url=”https://ocicpm.compat.objectstorage.ap-sydney-1.oraclecloud.com“
)
# Print out bucket names
for bucket in s3.buckets.all():
print(bucket.name)
# Upload a File to you OCI Bucket, 2nd value is your bucket name
s3.meta.client.upload_file(‘/tmp/hello.txt’, ‘Shadab-DB-Migrate’, ‘hello.txt’)
Reference:
——————-
[1] https://docs.cloud.oracle.com/en-us/iaas/Content/Object/Tasks/s3compatibleapi.htm
[2] https://docs.cloud.oracle.com/en-us/iaas/Content/Identity/Tasks/managingcredentials.htm#Working2LikeBe the first to like this