Resource Policy help - allow AWS Lex to access deployed Lambda function

Came across this a couple years later but have worked it out with some help from the solution mentioned here:

functions:
  lex-handler:
    description: 'Lex Chatbot Lambda function'
    handler: index.handler
    timeout: 20 # optional, in seconds, default is 6
resources:
  Resources:
    #
    # Lambda resource permission to allow Lex to invoke it
    # NOTE - Serverless tries to create resources first so you'll need to comment this
    #        out on first install and then run again to apply this permission
    #
    LambdaPermissionInvokeFromLex:
      Type: AWS::Lambda::Permission
      Properties:
        FunctionName: arn:aws:lambda:${aws:region}:${aws:accountId}:function:${self:service}-${self:provider.stage}-lex-handler
        Action: lambda:InvokeFunction
        Principal: lexv2.amazonaws.com

One caveat is that it tries to create resources first and fails because the Lambda does not exist yet.

So I deployed once with the resource commented out and then uncommented and ran again once the Lambda was created. There might be a better solution to that though.