User Tools

Site Tools


cloud:recipe:s3

This is an old revision of the document!


S3 Quickstart (demo)

This document is a recipe showing how to use S3 interface for first-time user. Before you start, see cli for setup. Ensure that you can authenticate and use the openstack client before proceeding.

Credentials

Obtain application credentials

openstack ec2 credentials create

Test Access with S3CMD Utility

Install the s3cmd utility

python3 -m pip install --user s3cmd

Edit ~/.s3cfg to include the credentials

[default]
access_key = <ACCESS KEY>
secret_key = <SECRET KEY>
host_base =  https://overcloud.cs.uchicago.edu:8000
host_bucket = https://overcloud.cs.uchicago.edu:8000

Test

s3cmd mb S3://chudler-bucket1
s3cmd ls S3://chudler-bucket1

Test Access with Python Boto (example)

Install boto library

python3 -m pip install --user boto
import boto
import boto.s3.connection
access_key = '<ACCESS_KEY>'
secret_key = '<SECRET_KEY>'

conn = boto.connect_s3(
        aws_access_key_id = access_key,
        aws_secret_access_key = secret_key,
        host = 'overcloud.cs.uchicago.edu:8000',
        is_secure=True,
        calling_format = boto.s3.connection.OrdinaryCallingFormat(),
)

for bucket in conn.get_all_buckets():
    print("{name}\t{created}".format(
            name = bucket.name,
            created = bucket.creation_date,
    ))
bucket = conn.get_bucket('chudler-bucket')
# key = bucket.new_key('hello.txt')
# key.set_contents_from_string('Hello World!')

# hello_key = bucket.get_key('hello.txt')
# hello_key.set_canned_acl('public-read') # UNSAFE! WATCH OUT!
# hello_key.set_canned_acl('private')
/var/lib/dokuwiki/data/attic/cloud/recipe/s3.1617647604.txt.gz · Last modified: 2021/04/05 13:33 by chudler