forked from mirkokiefer/aws-lib
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathec2.js
40 lines (32 loc) · 898 Bytes
/
ec2.js
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
exports.init = init;
function init(genericAWSClient) {
return createEC2Client;
function createEC2Client(accessKeyId, secretAccessKey, options) {
options = options || {};
var client = genericAWSClient({
host: options.host || "ec2.amazonaws.com",
path: options.path || "/",
accessKeyId: accessKeyId,
secretAccessKey: secretAccessKey,
secure: options.secure,
token: options.token
});
return {
client: client,
call: call
};
function call(action, opts, callback) {
var query = {
"Action": action,
"Version": options.version || "2012-12-01",
"SignatureMethod": "HmacSHA256",
"SignatureVersion": "2"
}
//add options to the end of the query
for(var key in opts){
query[key] = opts[key];
}
return client.call(action, query, callback);
}
}
}