-
Notifications
You must be signed in to change notification settings - Fork 0
/
s3SDK.js
37 lines (34 loc) · 1.15 KB
/
s3SDK.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
'use strict'; // eslint-disable-line strict
const S3 = require('aws-sdk').S3;
const configFile = require('./config.json');
// User will be subject of policies
const userAccessKeyId = configFile.user.accessKey;
const userSecretAccessKey = configFile.user.secretKey;
// Account will be used to create buckets and do other set up
// that user is not granted permission to perform
const accountAccessKeyId = configFile.account.accessKey;
const accountSecretAccessKey = configFile.account.secretKey;
const config = {
sslEnabled: false,
logger: process.stdout,
endpoint: configFile.s3Endpoint,
apiVersions: { s3: '2006-03-01' },
signatureCache: false,
signatureVersion: 'v4',
region: 'us-east-1',
s3ForcePathStyle: true,
};
const userConfig = Object.assign({
accessKeyId: userAccessKeyId,
secretAccessKey: userSecretAccessKey,
},
config);
const userClient = new S3(userConfig);
const accountConfig = Object.assign({
accessKeyId: accountAccessKeyId,
secretAccessKey: accountSecretAccessKey,
},
config);
const accountClient = new S3(accountConfig);
const s3Clients = { userClient, accountClient };
module.exports = s3Clients;