3

I need to use multiple AWS credentials for different services like s3, SNS....

var awsS3 = require('aws-sdk');
var awsSes = require('aws-sdk');

awsS3.config.update({
    region: config.awsRegion,
    accessKeyId: config.sesAccessKeyId,
    secretAccessKey: config.sesSecretAccessKey
});

awsSes.config.update({
    region: config.s3Region,
    accessKeyId: config.s3AccessKeyId,
    secretAccessKey: config.s3SecretAccessKey
  });

But above code is not working.

How to configure multiple accessKeyIds, secretAccessKeys for different services?

trinath
  • 433
  • 1
  • 5
  • 19
  • have you tried something like const aws = require('aws-sdk'); const s3 = new aws.S3({ /* credentials for s3*/ }); const ses = new aws.SES({ /* credentials for ses*/ }); I'm not sure if this works but I can't try it myself atm. – axanpi Jan 23 '20 at 16:07
  • did you find an answer? – Francesco Clementi Feb 11 '21 at 09:15

2 Answers2

5

You can pass config while creating service objects. Following is what you are looking for

const s3 = new aws.S3({ /* s3 config */ });
const ses = new aws.SES({ /* ses config */ });
karthikdivi
  • 3,466
  • 5
  • 27
  • 46
0

I would think you want to control it with policies instead of having multiple credentials. Use a single credentials/role, then custom policies on what you want to allows and deny for each service. Then your application can use that role/credentials and will be allows or restricted base on the policies.

noobius
  • 1,529
  • 7
  • 14