amazon web services - How to keep only Latest "N" number of files/objects in S3 bucket periodically using bash script or any other methods -
i using s3 bucket store web application log files. need know there option available, keep latest 20 files only, regardless when created. can't use s3 auto expiry option need latest 20 files inside bucket.
option 1:-
a) use s3 notification service , trigger lambda each put object in s3
b) list objects in bucket using python boto sdk , store values(key,date modified) in list .
c) sort list date/time , delete old record data 21st data.
option 2:-
a) configure sqs in notification service , trigger lambda each put object.
b) schedule lambda service based on requirements.
c) list objects in bucket using python boto sdk , store values(key,date modified) in list .
d) sort list date/time , delete old record data 21st data.
based on requirements need choose option 1 (or) option 2.
if file write/read/download in s3 bucket time intensive operation choose option 1
if file write/read/download not time intensive operation choose option 2.
Comments
Post a Comment