Skip to content

Instantly share code, notes, and snippets.

@andreybleme
Created April 11, 2019 18:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreybleme/7f88229382a6270ee62e94adbb923172 to your computer and use it in GitHub Desktop.
Save andreybleme/7f88229382a6270ee62e94adbb923172 to your computer and use it in GitHub Desktop.
andreybleme.com | Criando uma CLI para fazer deploy de sites estáticos
const AWS = require('aws-sdk')
function setAwsCredentials(awsCredentials) {
AWS.config.update(awsCredentials)
}
function createBucket(bucketParams, staticHostParams) {
const s3 = new AWS.S3()
s3.createBucket(bucketParams, function(err, data) {
if (err) {
console.log('Error creating bucket: ', err)
} else {
console.log('Successfully created bucket at ', data.Location)
setPoliciesForWebSiteHosting(staticHostParams)
}
});
}
function setPoliciesForWebSiteHosting(staticHostParams) {
const s3 = new AWS.S3()
s3.putBucketWebsite(staticHostParams, function(err, data) {
if (err) {
console.log('Error defining policies: ', err)
} else {
console.log('Successfully defined static hosting policies.')
}
});
}
module.exports = {
setAwsCredentials,
createBucket
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment