Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can make figure out file dependencies in AWS S3 buckets?

The source directory contains numerous large image and video files.

These files need to be uploaded to an AWS S3 bucket with the aws s3 cp command. For example, as part of this build process, I copy my image file my_image.jpg to the S3 bucket like this: aws s3 cp my_image.jpg s3://mybucket.mydomain.com/

I have no problem doing this copy to AWS manually. And I can script it too. But I want to use the makefile to upload my image file my_image.jpg iff the same-named file in my S3 bucket is older than the one in my source directory.

Generally make is very good at this kind of dependency checking based on file dates. However, is there a way I can tell make to get the file dates from files in S3 buckets and use that to determine if dependencies need to be rebuilt or not?

like image 213
Saqib Ali Avatar asked Dec 30 '17 03:12

Saqib Ali


People also ask

How do I extract files from S3 bucket?

In the Amazon S3 console, choose your S3 bucket, choose the file that you want to open or download, choose Actions, and then choose Open or Download. If you are downloading an object, specify where you want to save it.

How do I view files in S3 bucket?

In AWS Explorer, expand the Amazon S3 node, and double-click a bucket or open the context (right-click) menu for the bucket and choose Browse. In the Browse view of your bucket, choose Upload File or Upload Folder. In the File-Open dialog box, navigate to the files to upload, choose them, and then choose Open.

How do I see how many files are in a S3 bucket?

Open the AWS S3 console and click on your bucket's name. In the Objects tab, click the top row checkbox to select all files and folders or select the folders you want to count the files for. Click on the Actions button and select Calculate total size.

Can S3 be used as a file system?

Amazon S3 is object storage. It is not a file system (eg C:\ drive). Rather, applications can place API calls to upload/download data. Amazon S3 can also make objects available via HTTP/s without having to run a web server.


1 Answers

The AWS CLI has an s3 sync command that can take care of a fair amount of this for you. From the documentation:

A s3 object will require copying if:

  • the sizes of the two s3 objects differ,
  • the last modified time of the source is newer than the last modified time of the destination,
  • or the s3 object does not exist under the specified bucket and prefix destination.
like image 186
Mike Patrick Avatar answered Sep 20 '22 20:09

Mike Patrick