node_loader.js
3.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
var util = require('./util');
util.isBrowser = function() { return false; };
util.isNode = function() { return true; };
// node.js specific modules
util.crypto.lib = require('crypto');
util.Buffer = require('buffer').Buffer;
util.domain = require('domain');
util.stream = require('stream');
util.url = require('url');
util.querystring = require('querystring');
util.environment = 'nodejs';
util.createEventStream = util.stream.Readable ?
require('./event-stream/streaming-create-event-stream').createEventStream : require('./event-stream/buffered-create-event-stream').createEventStream;
util.realClock = require('./realclock/nodeClock');
util.clientSideMonitoring = {
Publisher: require('./publisher').Publisher,
configProvider: require('./publisher/configuration'),
};
util.iniLoader = require('./shared-ini').iniLoader;
var AWS;
/**
* @api private
*/
module.exports = AWS = require('./core');
require('./credentials');
require('./credentials/credential_provider_chain');
require('./credentials/temporary_credentials');
require('./credentials/chainable_temporary_credentials');
require('./credentials/web_identity_credentials');
require('./credentials/cognito_identity_credentials');
require('./credentials/saml_credentials');
require('./credentials/process_credentials');
// Load the xml2js XML parser
AWS.XML.Parser = require('./xml/node_parser');
// Load Node HTTP client
require('./http/node');
require('./shared-ini/ini-loader');
// Load custom credential providers
require('./credentials/token_file_web_identity_credentials');
require('./credentials/ec2_metadata_credentials');
require('./credentials/remote_credentials');
require('./credentials/ecs_credentials');
require('./credentials/environment_credentials');
require('./credentials/file_system_credentials');
require('./credentials/shared_ini_file_credentials');
require('./credentials/process_credentials');
// Setup default chain providers
// If this changes, please update documentation for
// AWS.CredentialProviderChain.defaultProviders in
// credentials/credential_provider_chain.js
AWS.CredentialProviderChain.defaultProviders = [
function () { return new AWS.EnvironmentCredentials('AWS'); },
function () { return new AWS.EnvironmentCredentials('AMAZON'); },
function () { return new AWS.SharedIniFileCredentials(); },
function () { return new AWS.ECSCredentials(); },
function () { return new AWS.ProcessCredentials(); },
function () { return new AWS.TokenFileWebIdentityCredentials(); },
function () { return new AWS.EC2MetadataCredentials(); }
];
// Update configuration keys
AWS.util.update(AWS.Config.prototype.keys, {
credentials: function () {
var credentials = null;
new AWS.CredentialProviderChain([
function () { return new AWS.EnvironmentCredentials('AWS'); },
function () { return new AWS.EnvironmentCredentials('AMAZON'); },
function () { return new AWS.SharedIniFileCredentials({ disableAssumeRole: true }); }
]).resolve(function(err, creds) {
if (!err) credentials = creds;
});
return credentials;
},
credentialProvider: function() {
return new AWS.CredentialProviderChain();
},
logger: function () {
return process.env.AWSJS_DEBUG ? console : null;
},
region: function() {
var env = process.env;
var region = env.AWS_REGION || env.AMAZON_REGION;
if (env[AWS.util.configOptInEnv]) {
var toCheck = [
{filename: env[AWS.util.sharedCredentialsFileEnv]},
{isConfig: true, filename: env[AWS.util.sharedConfigFileEnv]}
];
var iniLoader = AWS.util.iniLoader;
while (!region && toCheck.length) {
var configFile = iniLoader.loadFrom(toCheck.shift());
var profile = configFile[env.AWS_PROFILE || AWS.util.defaultProfile];
region = profile && profile.region;
}
}
return region;
}
});
// Reset configuration
AWS.config = new AWS.Config();