override def handleRequest()

in lambda/input/src/main/scala/InputLambdaMain.scala [410:474]


  override def handleRequest(event:S3Event, context:Context): Unit = {
    println(s"Lambda was triggered with: \n${dumpEventData(event, Some("\t"))}")
    val resultList = event.getRecords.asScala.map(rec=>{

      val path = URLDecoder.decode(rec.getS3.getObject.getKey,"UTF-8")

      println(s"Source object is s3://${rec.getS3.getBucket.getName}/$path version ${rec.getS3.getObject.getVersionId} in ${rec.getAwsRegion}")
      println(s"Event was sent by ${rec.getUserIdentity.getPrincipalId}")

      rec.getEventName match {
        /*
        All of these events indicate new content
         */
        case "ObjectCreated:Put"=>
          handleCreated(rec, path)
        case "ObjectCreated:Post"=>
          handleCreated(rec, path)
        case "ObjectCreated:CompleteMultipartUpload"=>
          handleCreated(rec, path)
        case "ObjectCreated:Copy"=>
          handleCreated(rec, path)

        /*
        All of these events indicate something was deleted, or an deletion attempt
         */
        case "ObjectRemoved:Delete"=> //object was _actually_ deleted
          handleRemoved(rec, path)
        case "ReducedRedundancyLostObject"=>
          handleRemoved(rec, path)
        case "LifecycleExpiration:Delete"=>
          handleRemoved(rec, path)
        case "ObjectRemoved:DeleteMarkerCreated"=> //object was _apparently_ deleted, leaving versions behind
          handleDeleteMarker(rec, path)
        case "LifecycleExpiration:DeleteMarkerCreated"=>  //lifecycle rule 'deleted' the object, leaving versions behind
          handleDeleteMarker(rec, path)

        /*
        All of these events relate to Glacier restores
         */
        case "ObjectRestore:Post"=> //restore has been initiated
          handleStarted(rec, path)
        case "ObjectRestore:Completed"=>  //restore has been completed
          handleRestored(rec, path)
        case "ObjectRestore:Delete"=>     //restore has expired and been dropped back
          handleExpired(rec, path)

        /*
        This relates to Standard -> IA -> Glacier -> Glacier Deep transitions
         */
        case "LifecycleTransition"=>      //s3 changed the storage tier
          handleTransition(rec, path)

        /*
        Default catch-all that shows an error
         */
        case other:String=>
          println(s"ERROR: received unknown event $other")
          throw new RuntimeException(s"unknown event $other received")
      }
    })

    //need to block here, AWS terminates the lambda as soon as the function returns.
    //as a bonus, if any of the operations fail this raises an exception and therefore is reported as a run failure
    Await.result(Future.sequence(resultList), 45.seconds)
  }