Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS S3 Sync with JS/Node SDK

Amazon Web Services - Command Line Interface (AWS-CLI) has a sync command. Unfortunately AWS CLI's sync method is a bit buggy. I'd like to sync to S3 using a gulp build process and Amazon's javascript/node SDK.

Unfortunately, the SDK doesn't seem to have a sync method, or does it?

What is the best way to sync whole directories in Node with AWS S3?

like image 396
Erik Avatar asked Apr 17 '14 09:04

Erik


People also ask

Does AWS S3 support JavaScript?

Amazon S3 provides easy to use object storage, with a simple web service interface to store and retrieve any amount of data from anywhere on the web. The JavaScript API for Amazon S3 is exposed through the AWS. S3 client class.

Can you run NodeJS on S3?

html is the root and files with paths such as js/ css/ images/ taken from the root folder. Note: Its important to understand that you cannot run NodeJS in S3 and instead you will be using the internal web hosting from S3 to serve the static content.

How do I use AWS S3 in node?

We can do this using the AWS management console or by using Node. js. To create an S3 bucket using the management console, go to the S3 service by selecting it from the service menu: Select "Create Bucket" and enter the name of your bucket and the region that you want to host your bucket.


1 Answers

The AWS CLI is more stable now. So, my solution:

gulp.task("sync-buckets", done => {
    let conf = loadConf();
    exec(`aws s3 sync --acl public-read bucket/www_static/ s3://${conf.BucketName}`, done);
});
like image 184
bedorlan Avatar answered Oct 15 '22 09:10

bedorlan