boto とboto3があるっぽい。boto3のが新しいっぽい
s3 file upload with boto3
pip install boto3
mkdir -p ~/.aws && echo "[default]
aws_access_key_id = YOUR_ACCESS_KEY_ID
aws_secret_access_key = YOUR_SECRET_ACCESS_KEY
" > ~/.aws/credentials
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# http://stackoverflow.com/questions/2253712/sharing-scripts-that-require-a-virtualenv-to-be-activated
#import commands
#print commands.getstatusoutput('python --version')
import os.path
target_file = 'syslog.1'
src_path = os.path.join('/var/log', target_file)
dest_path = os.path.join('.', target_file)
upload_target_path = dest_path
#import shutil
#shutil.copy2(src_path, '.')
import boto3
s3 = boto3.resource('s3')
#for bucket in s3.buckets.all():
# print(bucket.name)
bucket_name = 'kkas-test-bucket'
s3.create_bucket(Bucket=bucket_name)
#s3.create_bucket(Bucket=bucket_name, CreateBucketConfiguration={
# 'LocationConstraint': 'us-east-1'})
s3.Object(bucket_name, target_file).put(Body=open(upload_target_path, 'rb'))
# Check for