Skip to content

Commit

Permalink
chore: add a script to update CF template file
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel910 committed Oct 10, 2023
1 parent 901560f commit 949052a
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions scripts/updateDeployTemplateInS3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const S3 = require("aws-sdk/clients/s3");
const yargs = require("yargs");
const fs = require("fs");
const path = require("path");

const args = yargs.argv;

if (!args.source) {
console.error(`Please specify a "--source" parameter!`);
process.exit(1);
}

(async () => {
const s3 = new S3({ region: process.env["AWS_REGION"] ?? "us-east-1" });
const templateKey = "cloudformation/DEPLOY_WEBINY_PROJECT_CF_TEMPLATE.yaml";

const fileSource = path.resolve(args.source);

console.log(`Updating key: ${templateKey}`);
console.log(`Source file: ${fileSource}`);
const newBody = fs.readFileSync(fileSource, "utf8");

const bucket = "webiny-public";
const config = { Bucket: bucket, Key: templateKey, Body: newBody, ACL: "public-read" };

console.log(`Uploading to "${bucket}" bucket...`);
try {
await s3.putObject(config).promise();
console.log(`\nSUCCESS: File was updated!`);
} catch (err) {
console.error(`\nERROR: ${err.message}`);
process.exit(1);
}
})();

0 comments on commit 949052a

Please sign in to comment.