in cfn/wrap.go [28:67]
func lambdaWrapWithClient(lambdaFunction CustomResourceFunction, client httpClient) (fn CustomResourceLambdaFunction) {
fn = func(ctx context.Context, event Event) (reason string, err error) {
r := NewResponse(&event)
funcDidPanic := true
defer func() {
if funcDidPanic {
r.Status = StatusFailed
r.Reason = "Function panicked, see log stream for details"
// FIXME: something should be done if an error is returned here
_ = r.sendWith(client)
}
}()
r.PhysicalResourceID, r.Data, err = lambdaFunction(ctx, event)
funcDidPanic = false
if err != nil {
r.Status = StatusFailed
r.Reason = err.Error()
log.Printf("sending status failed: %s", r.Reason)
} else {
r.Status = StatusSuccess
if r.PhysicalResourceID == "" {
log.Println("PhysicalResourceID must exist on creation, copying Log Stream name")
r.PhysicalResourceID = lambdacontext.LogStreamName
}
}
err = r.sendWith(client)
if err != nil {
reason = err.Error()
}
return
}
return
}