Minimal AWS Elasticsearch connector
Creates a clone of the http class that signs each request before its sent.
Usage:
var elasticsearch = ;elasticsearch; var client = host : 'xxxxx.es.amazonaws.com' amazonES: region : 'us-east-1' accessKey : 'XXXX' secretKey : 'XXXX'
Config variables service
, region
, accessKey
and secretKey
can be defined in an amazonES
object at client creation. Alternatively, service defaults to 'es', region defaults to 'us-east-1' and the keys default to environment variables: AWS_ACCESS_KEY_ID
and AWS_SECRET_ACCESS_KEY
The complete code is as follows:
var aws4 = ; module { var pool = esConnectionPool http = poolconnectionClasseshttp; var { http; }; ; awsprototype { this_amazonES = configamazonES || {}; httpprototypecreateAgent; }; awsprototype { var params = httpprototypemakeReqParams; paramsbody = _paramsbody; paramsheaders = paramsheaders || {}; paramsheaders'Content-Type' = paramsheaders'Content-Type' || 'application/json'; if paramsgzip === undefined paramsgzip = true; var config = this_amazonES; paramsservice = configservice || 'es'; paramsregion = configregion || 'us-east-1'; aws4; return params; }; pooldefaultConnectionClass = 'aws'; poolconnectionClassesaws = aws; return es;};