diff --git a/cfn/wrap.go b/cfn/wrap.go index df1f4ae7..1bf6487d 100644 --- a/cfn/wrap.go +++ b/cfn/wrap.go @@ -42,16 +42,17 @@ func lambdaWrapWithClient(lambdaFunction CustomResourceFunction, client httpClie r.PhysicalResourceID, r.Data, err = lambdaFunction(ctx, event) funcDidPanic = false - if r.PhysicalResourceID == "" { - log.Println("PhysicalResourceID must exist, copying Log Stream name") - r.PhysicalResourceID = lambdacontext.LogStreamName - } 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)