Jan-28-2020, 09:03 PM
First of all: I am not familiar with Python, so I am asking for help to fix the existing script. There is a Python script (Lambda function) for deleting files having time stamps from S3 bucket:
https://gist.github.com/pwilken/b548b589...9ebadae59f
However it is failing at:
time stamp in S3 looks like: Jan 27, 2020 4:36:02 PM GMT+0000
so it is probably not expecting year here:
https://gist.github.com/pwilken/b548b589...9ebadae59f
However it is failing at:
Error: [ERROR] IndexError: list index out of range
Traceback (most recent call last):
File "/var/task/lambda_function.py", line 34, in lambda_handler
hour = dateArray[1].split(":")[0]
time stamp in S3 looks like: Jan 27, 2020 4:36:02 PM GMT+0000
so it is probably not expecting year here:
# Start Policy for everything older then one week date = obj["Key"].replace('prefix_before_time', '') dateArray = date.split("T") date = dateArray[0] hour = dateArray[1].split(":")[0] print(f' {date} - {hour}')Do anyone know how to fix it?