douzhi6365 2019-06-14 11:14
浏览 45
已采纳

如何在Go中创建AWS Lambda以处理多个事件

I need to implement the AWS Lambda handler to handle AWS S3Events & SNSEvent, any solution?

Already I checked this answer, How to support more than one trigger in AWS Lambda in Golang?

But that's doesn't work for me.

  • 写回答

1条回答 默认 最新

  • dsfs504545 2019-06-14 11:22
    关注

    According to this document you could hanlde your custom event. So you can create custom event which includes S3Entity and SNSEntity

    type Record struct {
       EventVersion         string           `json:"EventVersion"`
       EventSubscriptionArn string           `json:"EventSubscriptionArn"`
       EventSource          string           `json:"EventSource"`
       SNS                  events.SNSEntity `json:"Sns"`
       S3                   events.S3Entity  `json:"s3"`
    }
    
    type Event struct {
        Records []Record `json:"Records"`
    }
    

    Then check the EventSource

    func handler(event Event) error {
       if len(event.Records) > 0 {
        if event.Records[0].EventSource == "aws:sns" {
           //Do Something
        } else {
           //Do Something
        }
      }
    
      return nil
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测