4

I have my nodejs lambda trying to index data into ES, but it's failing because of this error:

2018-01-15T23:39:09.578Z (node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 131): Authorization Exception ::

User: anonymous is not authorized to perform: es:ESHttpPost on resource: ****

I have applied AmazonESFullAccess policy to the Lambda function role.
What am I missing?

1 Answer 1

7

I was able to resolve this issue. Code was missing 'connectionClass' and 'amazonES' parameters.

var AWS = require('aws-sdk');
var connectionClass = require('http-aws-es');
var elasticsearch = require('elasticsearch');
var elasticClient = new elasticsearch.Client({  
    host: ***,
    log: 'error',
    connectionClass: connectionClass,
    amazonES: {
      credentials: new AWS.EnvironmentCredentials('AWS')
    }
});
Sign up to request clarification or add additional context in comments.

2 Comments

This solution worked for me but I had to set the default region on the AWS object. AWS.config.region = "us-east-1"; github.com/TheDeveloper/http-aws-es/issues/44
I was getting the same error before User: anonymous is not authorized to perform: es:ESHttpPost. But after adding this, I am getting No Living connections. What might be going wrong?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.