How to use the config function from aws-sdk

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

40
41
42
43
44
45
46
47
48
49
    } else {
      core.info(`Setting proxy from environment: ${proxyFromEnv}`);
      proxyToSet = proxyFromEnv;
    }

    aws.config.update({
      httpOptions: { agent: proxy(proxyToSet) }
    });
  }
}
fork icon161
star icon714
watch icon23

434
435
436
437
438
439
440
441
442
443
444
445
};


exports.fetch_credentials = async (event, context) => {
  const awsCredentials = {
    accessKeyId: AWS.config.credentials.accessKeyId,
    secretAccessKey: AWS.config.credentials.secretAccessKey,
    sessionToken: AWS.config.credentials.sessionToken,
  };


  return response(200, 'application/json', JSON.stringify(awsCredentials));
fork icon450
star icon638
watch icon0

+ 17 other calls in file

274
275
276
277
278
279
280
281
282
283
  t.equal(req.body['MessageAttributes.entry.2.Value.StringValue'], 'es=s:1', 'tracestate message attribute StringValue')

  t.end()
})

AWS.config.update({
  endpoint: `http://localhost:${port}`
})
agent.startTransaction('myTransaction')
const publishTextPromise = new AWS.SNS({ apiVersion: '2010-03-31' })
fork icon211
star icon536
watch icon296

+ 132 other calls in file

772
773
774
775
776
777
778
779
780
781
782
783
  return params
}


function initializeAwsSdk () {
  // SDk requires a region to be set
  AWS.config.update({ region: 'us-west' })


  // without fake credentials the aws-sdk will attempt to fetch
  // credentials as though it was on an EC2 instance
  process.env.AWS_ACCESS_KEY_ID = 'fake-1'
fork icon211
star icon536
watch icon296

+ 18 other calls in file

37
38
39
40
41
42
43
44
45
46
47
48
49


initializeAwsSdk()


function initializeAwsSdk () {
  // SDk requires a region to be set
  AWS.config.update({ region: AWS_REGION })


  // without fake credentials the aws-sdk will attempt to fetch
  // credentials as though it was on an EC2 instance
  process.env.AWS_ACCESS_KEY_ID = 'fake-1'
fork icon211
star icon536
watch icon296

+ 104 other calls in file

61
62
63
64
65
66
67
68
69
70

// Example with AWS SDK V2:
getCredentials: () =>
  new Promise((resolve, reject) => {
    // Any other method to acquire a new Credentials object can be used.
    AWS.config.getCredentials((err, credentials) => {
      if (err) {
        reject(err);
      } else {
        resolve(credentials);
fork icon90
star icon121
watch icon23

35
36
37
38
39
40
41
42
43
44
const writerWebSocketApiId = findOutput(cloudformationOutputs, 'WriterWebSocketApiId');

const readerWebSocketApiId = findOutput(cloudformationOutputs, 'ReaderWebSocketApiId');

// Delete stages
AWS.config.update({ region: awsRegion });
const apigatewayv2 = new AWS.ApiGatewayV2();

const deleteStageWriterParams = {
  ApiId: writerWebSocketApiId,
fork icon18
star icon42
watch icon11

4
5
6
7
8
9
10
11
12
13
const delay = require('delay');
const RestAPI = require('./restapi');
const utils = require('./utils');

function APIGateway(options) {
        AWS.config.region = options.awsRegion || 'us-west-1';

        if (options.awsProfile) {
                // Set the `credentials` property if a profile is provided
                const objectCredentials = {
fork icon2
star icon1
watch icon4

+ 3 other calls in file

106
107
108
109
110
111
112
113
114
115
           return Promise.resolve({ Account: FAKE_ROLE_ACCOUNT_ID });
        }
    });

aws.config.getCredentials.mockReset();
aws.config.getCredentials
    .mockImplementationOnce(callback => {
        if (!aws.config.credentials) {
            aws.config.credentials = {
                accessKeyId: FAKE_ACCESS_KEY_ID,
fork icon388
star icon0
watch icon0

+ 7 other calls in file

99
100
101
102
103
104
105
106
107
108
    makeImdsConfigSource(),
    makeSecretsManagerConfigSource('ConfSecret'),
    makeAutoScalingGroupConfigSource(),
  ]);

  AWS.config.update({ region: loader.config.awsRegion });
},
(callback) => {
  // Initialize CloudWatch logging if it's enabled
  if (module.exports.config.useCloudWatchLogging) {
fork icon256
star icon256
watch icon15

43
44
45
46
47
48
49
50
51
52
return new Promise((resolve, reject) => {
  AWS.config.credentials.get(function (err) {
    if (!err) {
      console.log('Retrieved identity: ' + AWS.config.credentials.identityId)
      const params = {
        IdentityId: AWS.config.credentials.identityId
      }
      cognitoIdentity.getCredentialsForIdentity(params, function (err, data) {
        console.log('Creds: ', data)
        if (!err) {
fork icon41
star icon0
watch icon0

+ 11 other calls in file

18
19
20
21
22
23
24
25
26
27
me.findService = function(input) {
    var params = {region:input.region};
    if (input.creds)  params.credentials = input.creds;
    else if (input.profile) {
        var credentials = new AWS.SharedIniFileCredentials({profile: input.profile});
        AWS.config.credentials = credentials;
    }
    var ec2 = new AWS.EC2(params);
    return ec2;
}
fork icon6
star icon29
watch icon21

3
4
5
6
7
8
9
10
11
12

'use strict';

var AWS = require('aws-sdk');
if(!AWS.config.region) {
        AWS.config.region = 'us-east-1';
}

var Resource = {
        resources: {
fork icon5
star icon146
watch icon10

-2
fork icon3
star icon44
watch icon4

+ 17 other calls in file

69
70
71
72
73
74
75
76
77
78
    config.httpOptions = { agent: new PROXY(opts) };
} else {
    config.httpOptions = { agent: new https.Agent(opts) };
}

AWS.config.update(config);
this.ec2 = new AWS.EC2();
this.s3 = new AWS.S3();

if (this.storageName) {
fork icon1
star icon12
watch icon16

16
17
18
19
20
21
22
23
24
25
  });
}

const region = session.roleArn.includes('aws-us-gov') ? 'us-gov-west-1' : 'us-east-1';

Aws.config.update({region});

const sts = new Aws.STS();

const refreshResponseObj = Object.assign({}, ResponseObj, {
fork icon39
star icon130
watch icon17

45
46
47
48
49
50
51
52
53
54
  ...options,
};

if (this.options.config) {
  if (typeof this.options.config === 'string') {
    AWS.config.loadFromPath(this.options.config);
  } else if (typeof this.options.config === 'object') {
    AWS.config.constructor(this.options.config);
  } else {
    throw new Error('unsupported config is passed as a argument.');
fork icon4
star icon15
watch icon8

+ 3 other calls in file

6
7
8
9
10
11
12
13
14
15
    return callback(null, false);
}

config = input.config;

AWS.config.update({region: input.awsRegion});
var awsConfig       = new AWS.ConfigService(),
    params = {};
switch (input.eventType) {
    case 'configRule':
fork icon8
star icon7
watch icon39

0
1
2
3
4
5
6
7
8
9
'use strict';

const AWS = require('aws-sdk');

module.exports.iot = async (event, context) => {
  AWS.config.update({region: process.env.AWS_REGION});

  const dynamodb = new AWS.DynamoDB.DocumentClient({apiVersion: '2012-08-10'});
  const dynamoTable = process.env.DYNAMODB_TABLE;
  
fork icon0
star icon1
watch icon1

+ 3 other calls in file

693
694
695
696
697
698
699
700
701
702
703
704
  return ret
}


function initSqs () {
  // Set the region
  AWS.config.update({ region: defaultRegion })


  // Create an SQS service object
  return new AWS.SQS({ apiVersion: '2012-11-05' })
}
fork icon1
star icon1
watch icon0

+ 3 other calls in file