S3 Event Notification - Download Object

,

I’m fairly new to AWS and I had a question about a pipeline I had planned.

Basically, I have objects being added to S3 at regular intervals (probably 10k/day). I want to leverage event notifications to sequentially download these objects to an on-prem object storage solution (minIO).

Here’s the workflow I’m considering:

  1. S3 event notifications are sent to SQS;
  2. SQS sends the message to a homebrew microservice that reads the event payload and downloads the object locally;
  3. The microservice… Communicates with SQS and deletes the message from the queue AFTER everything is downloaded correctly (to ensure the atomicity of the transaction).

Just curious what thoughts are about this architecture, if it sounds reasonable. Would greatly appreciate feedback, no matter how scathing.

  1. You mean, the microservice polls the queue at regular intervals?

If you intend to access the files multiple times locally and has spare storage, it’s a good strategy to save some egress bandwidth.

If the access is infrequent you may only store the metadata in a DB and change the objects to cheaper storage classes.

Or you can just save the metadata to dynamo. 1 wcu at this rate will do the job and won’t be expensive.

Many ways to skin this cat. I don’t see anything particularly wrong with your solution. Event driven architecture still feels like a Rube Goldberg machine to me at times. Just be deliberate in your queue/de queue logic so as to ensure integrity.

Yeah, I apologize, I think this speaks to my inexperience with the services.

I guess I’m seeking to subscribe to these notifications-- ideally some AWS tool would “publish” this event and my service would be listening and handle these events. I was drawn to SQS for availability reasons, in case my tool fails and I do not complete storing an object locally. I apologize if that’s not clear.

I do not intend to access these files multiple times. I’m looking at one pull into my on-premises storage per object.

Look into SNS instead of SQS. SNS can deliver messages to your HTTPS endpoint.

Check the section “Creating an HTTP/S delivery policy” in here regarding setting up a delivery policy on SNS to deal with your tool’s potential failures.

This is exactly what I was looking for! Thank you so much!

For what you’re attempting to do SQS with long polling is the cheapest, most reliable and less error prone option.

With S3 you’ll only be able to send events to sqs, sns or Lambda.

If you’re looking for a push based solution from S3 to your microservice you can use SNS as bridge to publish to an http endpoint subscription. To support this your infra will have to support http ingress and you’ll have to set up a DLQ for the subscription: if your service goes down or the link is broken, sns will stop sending eventually and discard the message if no DLQs are configured, which means you can’t escape SQS.

For push you can Dynamo streams or kinesis too, which waives you from an http ingress since the clients (your microservice) will be the ones connecting and then listening to either. The implementation is a bit more involved code and maintain. Both have similar apis (shard iterators) and you are responsible for storing the “checkpoint” to resume the streaming in case it breaks.

i would use lambda if the object storage is network attached, so you don’t have to run the micro-service all the time. other than that it looks good!

What you’re proposing sounds reasonable to me.

I would just add as a suggestion: Enable S3 Inventory reports on the bucket and create a backup flow that uses the Inventory Report as the source of truth to find any missing files. Perhaps I’m just overly pessimistic, but invariably with a solution like this I find someone deployed the version with the “DEBUG_PRETEND_TO_DO_WORK” flag set for an hour before realizing their mistake. It’s useful to have a way out of messes like that.

(There’s no technical reason a backup flow couldn’t just list the objects itself, it’s just once you start talking about hundreds of thousands or more objects, it’s much faster to consume a CSV file instead)

Not sure what your on-prem storage requirements are, but have you considered using File Gateway instead of building your own solution? It provides access to S3 data via an on-prem NFS or SMB interface with local caching.