def _connect(self, instance):
        for e in ("access_id", "access_secret"):
            if e not in instance:
                raise Exception("{0} parameter is required.".format(e))

        s3_settings = {
            "aws_access_key_id": instance.get('access_id', None),
            "aws_secret_access_key": instance.get('access_secret', None),
            "proxy": instance.get('host', 'localhost'),
            "proxy_port": int(instance.get('port', 8080)),
            "is_secure": _is_affirmative(instance.get('is_secure', True))
        }

        if instance.get('s3_root'):
            s3_settings['host'] = instance['s3_root']

        aggregation_key = s3_settings['proxy'] + ":" + str(s3_settings['proxy_port'])

        try:
            s3 = S3Connection(**s3_settings)
        except Exception, e:
            self.log.error("Error connecting to {0}: {1}".format(aggregation_key, e))
            self.service_check(
                self.SERVICE_CHECK_NAME, AgentCheck.CRITICAL,
                tags=["aggregation_key:{0}".format(aggregation_key)],
                message=str(e))
            raise

        tags = instance.get("tags", [])
        tags.append("aggregation_key:{0}".format(aggregation_key))

        return s3, aggregation_key, tags
dataset/ETHPy150Open serverdensity/sd-agent/checks.d/riakcs.py/RiakCs._connect/original