Specify version to lambda function

Following https://serverless.com/framework/docs/providers/aws/guide/functions#versioning-deployed-functions, the versioning does not seem to be working, as be default this should be enabled.
But when I try to associate the lambda function to CloudFront, I get this error:

(Service: AmazonCloudFront; Status Code: 400; Error Code: InvalidLambdaFunctionAssociation)

I am basically trying to recreate https://medium.com/@robpope/aws-cloudfront-lambda-robots-txt-17950701af in serverless framework.

Any advice is much appreciated