Skip to content

IAM role - session token expiring issue (question) #53

Open
@ilamarang

Description

@ilamarang

Hi,
I prefer to use a singleton connection for connecting to elastic search - We use an IAM role rather than IAM user for security reasons.

I'm receiving a 403 error after the session token expires - Does this library interact with aws-sdk to refresh tokens ? (or) is this something that should be handled outside of this library ?

var AWS = require('aws-sdk');
var config = require('config');
var connectionClass = require('http-aws-es');
var elasticsearch = require('elasticsearch');

AWS.config.getCredentials(function() {

AWS.config.update({
  credentials: new AWS.Credentials(AWS.config.credentials.accessKeyId,AWS.config.credentials.secretAccessKey,AWS.config.credentials.sessionToken),
  region: 'us-east-1'
});

}

)

var client = new elasticsearch.Client({
  host: `${config.get('elasticSearch.host')}`,
  log: 'debug',
  connectionClass: connectionClass,
  amazonES: {
    credentials: new AWS.EnvironmentCredentials('AWS')
  }
   
});

module.exports = client;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions