I am building an AWS Lambda function in Golang that copy the content from n to m S3 buckets. There is a requirement to support for S3 trigger as well as fetching the data from an SQS where all source S3 bucket change is stored. The code can be found here: https://github.com/maknahar/s3copy
I tried following:
func main() {
lambda.Start(ProcessIncomingS3Events)
lambda.Start(ProcessIncomingEvents)
}
func ProcessIncomingS3Events(event events.S3Event) error {
...
log.Println("Got S3 Event")
return processS3Trigger(config, event)
}
func ProcessIncomingEvents() error {
...
log.Println("Defaulting to SQS")
return processSQSMessage(config)
}
In this case, the first event ProcessIncomingS3Events is triggered every time.
I tried following as well
func main() {
lambda.Start(ProcessIncomingEvents)
}
func ProcessIncomingEvents(event interface{}) error {
...
switch request := event.(type) {
case events.S3Event:
log.Println("Got S3 Event")
return processS3Trigger(config, request)
case types.Nil:
log.Println("Defaulting to SQS")
return processSQSMessage(config)
default:
log.Println("Could not find the event type")
}
return nil
}
In this case, Lambda could not detect the type and Could not find the event type is logged in every trigger.
Is there a way to support multiple triggers via AWS SDK at all for the function?