Quick Start to S3 API for Cloud Object Storage
Prerequisites
To get started, you'll need to setup the Openstack CLI client to generate credentials you can use with the S3 API. You can follow this guide for instructions, ensuring when you export credentials you select the region you've created your object stores in.
Generating S3-Compatible Credentials
Once you've gotten the Openstack CLI client working, you can run ec2 credentials create to create the credentials you will use to access object storage via the S3 compatible API. That output will look something like this:
$ openstack ec2 credentials create
+------------+----------------------------------+
| Field | Value |
+------------+----------------------------------+
| access | 00000000000000000000000000000000 |
| links | {'self': '[...]'} |
| project_id | 00000000000000000000000000000000 |
| secret | 00000000000000000000000000000000 |
| trust_id | None |
| user_id | 00000000000000000000000000000000 |
+------------+----------------------------------+
Copy the "access" and "secret" values to somewhere safe. Those are the "access key ID" and "secret access key" values you will use with your client.
S3 Endpoint
The endpoint to use for your client will be the controller domain name on port 8080. Going based on the domain name in the OS_AUTH_URL of the openrc file, the endpoint would be https://lax-controller.ramnode.com:8080.
S3 Browser Example
If you were using the S3 Browser application to utilize the S3 API it would look something like this:
Python Example
Below is an example for listing objects (files) using the boto3 Python library.
import boto3
# Assign your credentials (replace with your own values)
ACCESS_KEY_ID = '00000000000000000000000000000000'
SECRET_ACCESS_KEY = '00000000000000000000000000000000'
# Set the appropriate API URL
S3_API_URL = 'https://lax-controller.ramnode.com:8080'
# Create an S3 client with your credentials and API URL
s3 = boto3.client('s3', aws_access_key_id=ACCESS_KEY_ID,
aws_secret_access_key=SECRET_ACCESS_KEY,
endpoint_url=S3_API_URL)
# Define the bucket and prefix you want to list objects for
bucket_name = 'ExampleBucket'
prefix = ''
# List objects in the bucket with the specified prefix
response = s3.list_objects(Bucket=bucket_name, Prefix=prefix)
# Print the object names
for obj in response['Contents']:
print(obj['Key'])
Frequently Asked Questions
How do I create an object store?
In the cloud control panel, open the sidebar, dropdown "Cloud", and click "Object store". Now select your region at the top right, and click the "+" button. If the button is greyed out, object storage is not currently supported in that region.
How do I manage ACLs/permissions on credentials?
At this time we are not aware of a way to manage permissions on credentials, meaning each credential has full access to all buckets.