Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Lambda function error
#1
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:

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?
Reply


Messages In This Thread
Lambda function error - by localsystemuser - Jan-28-2020, 09:03 PM
RE: Lambda function error - by ibreeden - Jan-28-2020, 09:42 PM
RE: Lambda function error - by localsystemuser - Jan-29-2020, 10:48 AM
RE: Lambda function error - by DeaD_EyE - Jan-29-2020, 01:43 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Add two resultant fields from python lambda function klllmmm 4 993 Jun-06-2023, 05:11 PM
Last Post: rajeshgk
  Writing a lambda function that sorts dictionary GJG 1 2,058 Mar-09-2021, 06:44 PM
Last Post: buran
  Why does lambda throw 'name value_o is not defined' error? karabakh 3 2,264 Dec-14-2020, 05:45 PM
Last Post: karabakh
  translating lambda in function fabs 1 2,192 Apr-28-2020, 05:18 AM
Last Post: deanhystad
  Lambda function recursion error DeadlySocks 1 2,115 Apr-13-2020, 05:09 PM
Last Post: deanhystad
  Help with AWS Lambda function faws2019 0 1,617 Aug-27-2019, 01:54 PM
Last Post: faws2019
  Lambda function Uchikago 3 2,761 Jul-16-2019, 08:56 AM
Last Post: perfringo
  eval lambda function with restricted context Olivier 7 5,248 Mar-04-2019, 10:45 PM
Last Post: Olivier
  Using a lambda function within another function JChapman 8 5,535 Jan-08-2019, 01:54 PM
Last Post: JChapman
  Write lambda function in pyhhon to coy data from multiple JSON into a single JSON fil anandmn85 2 4,290 Apr-19-2018, 05:56 AM
Last Post: anandmn85

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020