forked from auth0/rules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added deploy script for automatic upload the rules.json to the aws s3 * exit with code 1 in case of error
- Loading branch information
Showing
5 changed files
with
1,114 additions
and
959 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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(); | ||
}); | ||
})(); |
Oops, something went wrong.