-
Notifications
You must be signed in to change notification settings - Fork 154
/
deploy.js
executable file
·38 lines (32 loc) · 1.01 KB
/
deploy.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
const aws = require('aws-sdk');
const rules = require('./rules.json');
require('dotenv').config();
(function () {
if (!process.env.S3_ACCESS_KEY || !process.env.S3_SECRET || !process.env.S3_REGION || !process.env.S3_BUCKET) {
console.log('AWS S3 settings missing. S3_ACCESS_KEY, S3_SECRET, S3_REGION and S3_BUCKET settings are required.');
process.exit(1);
}
console.log(`Deploying rules.json into ${process.env.S3_BUCKET} bucket...`);
const S3 = new aws.S3({
accessKeyId: process.env.S3_ACCESS_KEY,
secretAccessKey: process.env.S3_SECRET,
sessionToken: process.env.S3_SESSION_TOKEN,
region: process.env.S3_REGION,
params: {
Bucket: process.env.S3_BUCKET
}
});
const params = {
Body: JSON.stringify(rules),
Key: 'rules/rules.json',
ContentType: 'application/json'
};
return S3.putObject(params, function(err) {
if (err) {
console.log(err);
process.exit(1);
}
console.log('rules.json deployed successfully.');
process.exit();
});
})();