Skip to content

Instantly share code, notes, and snippets.

@jaxoncreed
Created August 18, 2018 15:19
Show Gist options
  • Save jaxoncreed/43052698d0d97c1a166ff2ecd757d1a5 to your computer and use it in GitHub Desktop.
Save jaxoncreed/43052698d0d97c1a166ff2ecd757d1a5 to your computer and use it in GitHub Desktop.
Modified script
const aws = require('aws-sdk');
var endpoint = new AWS.Endpoint('https://search-arduino-test-ybrxss46t4wvvczoi5tipwrvz4.us-west-2.es.amazonaws.com');
exports.handler = function(event, context) {
var req = new AWS.HttpRequest(endpoint);
req.method = 'POST';
req.path = path.join('/', esDomain.index, esDomain.doctype);
req.region = esDomain.region;
req.body = event;
req.headers['presigned-expires'] = false;
req.headers['Host'] = endpoint.host;
// Sign the request (Sigv4)
// var signer = new AWS.Signers.V4(req, 'es');
// signer.addAuthorization(creds, new Date());
// Post document to ES
var send = new AWS.NodeHttpClient();
send.handleRequest(req, null, function(httpResp) {
var body = '';
httpResp.on('data', function (chunk) {
body += chunk;
});
httpResp.on('end', function (chunk) {
console.log(body);
context.succeed();
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment