def _get_s3_conn(ud):
    try:
        if 'cloud_type' in ud and ud['cloud_type'] != 'ec2':
            # If the user has specified a cloud type other than EC2,
            # create an s3 connection using the info from their user data
            log.debug('Establishing boto S3 connection to a custom Object Store')
            try:
                s3_conn = S3Connection(aws_access_key_id=ud['access_key'],
                        aws_secret_access_key=ud['secret_key'],
                        is_secure=ud.get('is_secure', True),
                        host=ud.get('s3_host', ''),
                        port=ud.get('s3_port', 8888),
                        calling_format=OrdinaryCallingFormat(),
                        path=ud.get('s3_conn_path', '/'))
            except S3ResponseError, e:
                log.error("Trouble connecting to a custom Object Store. User data: {0}; Exception: {1}"\
                    .format(ud, e))
        else:
            # Use the default Amazon S3 connection
            log.debug('Establishing boto S3 connection to Amazon')
            s3_conn = S3Connection(ud['access_key'], ud['secret_key'])
    except Exception, e:
        log.error("Exception getting S3 connection: %s" % e)
        return None
    return s3_conn
dataset/ETHPy150Open chapmanb/cloudbiolinux/installed_files/ec2autorun.py/_get_s3_conn/original