I have a file in S3 that is being continuously modified. I will have to read it and display it live on the stdout
.
That is, I read the first line, and if the file is modified and a second line is added, I will have to reflect those changes in my stdout
. I want all of this to happen in a single command and without running the command multiple times to read the updated file.
I need a golang functionality like bash command "tail -f <FILENAME>
" that reads a S3 file from COS.
The design you are proposing will not work correctly
This is because
Amazon S3 offers eventual consistency for overwrite PUTS and DELETES in all regions.
(see Introduction to S3)
What this means in practice is that overwriting or updating an S3 object does not quickly allow reads of the same object - which is what you need to "tail" a file
I suggest you rethink the way you are monitoring the file
You haven't said why you wish to tail the file but (for example) if you are simply looking for activity then Cloudwatch can be used to get various rate metrics from S3
If your originating file is on an EC2 instance then Cloudwatch Logs might be a good fit