I’m using a service who provide many .gz files and I want to transfer them to my S3 bucket. The client update these files every day. I have to stay in sync with his server and my S3 Bucket.
The idea is to create an Lambda (called every day) who would be in charge to transfer these .gz files directly from his server to my Bucket.
I’ve no idea how to do that.
They provide an API with all endpoints where these files are stored.
If you are able, deploy a storage gateway and do an SMB/NFS mount. From the host, you can create a task to either copy the files over everyday or just write direct. I think Lambda would just be complicating things as it’s attempting to trigger an action on premise.
I have a similar use case with files provided via SFTP. My general process is SFTP → temp storage → S3. Is there a way to bypass the temp storage step?
Storage gateway is also an over-complicated solution. You also don’t get direct file access in s3 as the ‘under the hood’ parts of storage gateway aren’t accessible to us. Besides, EFS would be a better way to provide a volume to an instance in terms of cost.
That said, having the instance itself run a cron job that runs an aws s3 sync script is the simplest way to accomplish what OP described.
assuming temp storage is a linux instance / server, you can use rclone (works like rsync but for cloud storage). Much better than aws cli. Rclone github
Careful, because as the number of files increases, the job has to process more and more files. We had a system where the lifecycle policy on the bucket kept the number of files low, but we still ran into problems with the Cron job running longer than the interval between Cron jobs.
I’m still having trouble understanding the entire situation here. Is the server an ec2 instance in a VPC? In that case you should definitely be making use of an S3 endpoint.
Are you fetching the files remotely through an API and then transferring them yourself into a bucket? If so, then the transfer point should be an ec2 instance inside of a VPC with a VPC endpoint for S3.
Also, are you for sure sure that every file that you catalog is new and definitely needs to go to the S3 bucket, or do you need to do some kind of logic where are you only push new objects to the bucket?
Agreed concerning cost on the gateway if the data is already in AWS as I just assumed it wasn’t (my bad). With Gateway you do have access to the bucket contents and can trigger a notify when upload call once everything is in s3 which can be used to then run additional tasks like tagging, object lock, call lambda, etc. Where it get’s tricky is if you want to modify or add new objects directly to the bucket associated to the gateway share as a refresh cache call when need to be made after each change to keep the cache/share contents updated. It appears we’re missing additional details (like source location and purpose) concerning this request. The ability to provide multiple solutions to a simple requirement is what makes AWS so fun (and frustrating).
You can run the Uppy Companion from Lambda and it takes care of taking uploading one or many files direct to S3.
You then have a script, local or in another lambda which runs on a schedule and uses the Uppy S3 Multipart Upload to post to your Uppy Companion lambda.
This process doesn’t require your lambda to have lots of memory or space as the Companion handles the direct to S3 upload.
I’ve used the AWS CLI for problems like this. You would use the sync command and configure a user policy that is locked down accept for writing to that specific bucket path where the files need to go.