def get_bucket_and_key(name): """Connect to S3 and grab bucket and key.""" key, secret, host = get_aws_info() conn = S3Connection(key, secret, host=host) try: bucket = conn.get_bucket(name) except boto.exception.S3ResponseError: bucket = conn.create_bucket(name) return bucket, boto.s3.key.Key(bucket)