How to add CloudWatch Lambda Insights to serverless config?

I found out that it isn't a setting but a layer in the lambda. I managed to create it with this piece of code:

provider:
  name: aws
  iamManagedPolicies:
    - "arn:aws:iam::aws:policy/CloudWatchLambdaInsightsExecutionRolePolicy"

functions:
  functionName:
    layers:
      - arn:aws:lambda:<REGION>:580247275435:layer:LambdaInsightsExtension:<VERSION>

The latest version of the lambda insights layer can be found at: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Lambda-Insights-extension-versions.html