One of the great points of AWS’s S3 is that you can get notifications about objects being uploaded/deleted/changed/etc.
Turns out Minio can do that too! See https://docs.min.io/docs/minio-bucket-notification-guide.html for details. A quick test using nsq as queue manager worked.
Start nsq as Docker container (on hosts t620.lan):
$ docker run --rm -p 4150-4151:4150-4151 nsqio/nsq /nsqd
Configure Minio:
$ mc admin config set cubie notify_nsq:1 nsqd_address="t620.lan:4150" queue_dir="" queue_limit="0" tls="off" tls_skip_verify="on" topic="minio"
Restart the minio server. It’ll now show one extra line when starting:
Dec 08 22:37:37 cubie minio[4502]: SQS ARNs: arn:minio:sqs::1:nsq
Now configure the actual events (any changes in the bucket “Downloads”):
$ mc event add cubie/Downloads arn:minio:sqs::1:nsq
After uploading a file I get an event like this:
{
"EventName": "s3:ObjectCreated:Put",
"Key": "Downloads/to-kuro.sh",
"Records": [
{
"eventVersion": "2.0",
"eventSource": "minio:s3",
"awsRegion": "",
"eventTime": "2020-12-08T13:40:56.970Z",
"eventName": "s3:ObjectCreated:Put",
"userIdentity": {
"principalId": "minio"
},
"requestParameters": {
"accessKey": "minio",
"region": "",
"sourceIPAddress": "192.168.1.134"
},
"responseElements": {
"content-length": "0",
"x-amz-request-id": "164EC17C5E9BEB3E",
"x-minio-deployment-id": "d3d81f71-a06c-451e-89be-b1dc4e891054",
"x-minio-origin-endpoint": "https://192.168.1.36:9000"
},
"s3": {
"s3SchemaVersion": "1.0",
"configurationId": "Config",
"bucket": {
"name": "Downloads",
"ownerIdentity": {
"principalId": "minio"
},
"arn": "arn:aws:s3:::Downloads"
},
"object": {
"key": "testscript.sh",
"size": 337,
"eTag": "5f604e1b35b1ca405b35503b86b56d51",
"contentType": "application/x-sh",
"userMetadata": {
"content-type": "application/x-sh"
},
"sequencer": "164EC17C6153CB1E"
}
},
"source": {
"host": "192.168.1.134",
"port": "",
"userAgent": "MinIO (linux; amd64) minio-go/v7.0.6 mc/2020-11-25T23:04:07Z"
}
}
]
}
Neat!