func LambdaWrapSNS()

in cfn/wrap.go [88:105]


func LambdaWrapSNS(lambdaFunction CustomResourceFunction) SNSCustomResourceLambdaFunction {
	inner := LambdaWrap(lambdaFunction)
	return func(ctx context.Context, event events.SNSEvent) (reason string, err error) {
		if len(event.Records) != 1 {
			err = errors.New("expected exactly 1 incoming record")
			return
		}

		message := event.Records[0].SNS.Message

		var innerEvent Event
		if err = json.Unmarshal([]byte(message), &innerEvent); err != nil {
			return
		}

		return inner(ctx, innerEvent)
	}
}