How to use the CredentialProviderChain function from aws-sdk

Find comprehensive JavaScript aws-sdk.CredentialProviderChain code examples handpicked from public code repositorys.

7
8
9
10
11
12
13
14
15
16
17
18


let credentials = {};


const setAWSCredentials = async () => {
  try {
    const credentialProviderChain = new AWS.CredentialProviderChain();
    credentials = await credentialProviderChain.resolvePromise();
  } catch (e) {
    console.error('Failed to get AWS credentials');
    throw e;
fork icon44
star icon71
watch icon0

9
10
11
12
13
14
15
16
17
18
19
const fs = require("fs");
const path = require("path");


const getCredentials = async () => {
  let credentials;
  let credProvider = new AWS.CredentialProviderChain();
  try {
    credentials = await new Promise((resolve, reject) => {
      credProvider.resolve(function (err, creds) {
        if (err) {
fork icon21
star icon162
watch icon0

-2
fork icon1
star icon0
watch icon0

+ 3 other calls in file

49
50
51
52
53
54
55
56
57
58
request.method = "GET";
request.path += `${index}/_doc/${workId}?_source=title,accession_number,file_sets`;
request.headers["host"] = elasticsearchEndpoint;
request.headers["Content-Type"] = "application/json";

let chain = new AWS.CredentialProviderChain();
chain.resolve((err, credentials) => {
  if (err) {
    console.error("Returning unsigned request: ", err);
  } else {
fork icon0
star icon0
watch icon0

+ 2 other calls in file

22
23
24
25
26
27
28
29
30
31
// Assumption is that loading only needs to happen once per execution and if refreshing is
// needed, credentials object should implement credentials.refresh() callback
if (!credentials) {
  if (useAwsChain) {
    isAwsCredentials = true
    credentials = await new AWS.CredentialProviderChain().resolvePromise()
  } else if (useAwsCredentials) {
    credentials = {
      accessKeyId: parent.options.awsAccessKeyId,
      secretAccessKey: parent.options.awsSecretAccessKey,
fork icon0
star icon0
watch icon0

118
119
120
121
122
123
124
125
126
127
	() => new AWS.EnvironmentCredentials("AMAZON"),
	() => new AWS.SharedIniFileCredentials({ profile: config.profile || "default" }),
	() => new AWS.EC2MetadataCredentials(),
];

(new AWS.CredentialProviderChain()).resolve((err, cred) => {
	if (err) {
		reject(err);
	}
	else {
fork icon0
star icon0
watch icon0

8
9
10
11
12
13
14
15
16
17
  () => new AWS.EnvironmentCredentials(prefix),
  () => new AWS.SharedIniFileCredentials({ profile: config.profile || 'default' }),
  () => new AWS.EC2MetadataCredentials()
];

const chain = new AWS.CredentialProviderChain();

chain.resolve((err, credentials) => {
  if (err) {
    return cb(err);
fork icon0
star icon0
watch icon1

+ 27 other calls in file