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?
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.
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.
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.
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);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With