Using env.yml AND sharing Outputs into environment

I am providing my environment with an env.yml file which lets me have a different variables for each stage:

provider:
  name: aws
  environment: ${file(env.yml):${opt:stage}}

I also need to share some output variables to Lambda which are declared like so:

  Outputs:
    UserPoolId:
      Value:
        Ref: QNABUserPool
      Export:
        Name: ${self:provider.stage}-UserPoolId

    UserPoolClientId:
      Value:
        Ref: QNABUserPoolClient
      Export:
        Name: ${self:provider.stage}-UserPoolClientId

I’ve seen I can do this by adding this to my provider but this conflicts with my env.yml

environment:
    COGNITO_USER_POOL_ID: ${cf:${self:service}-${self:provider.stage}.UserPoolId}
    COGNITO_USER_POOL_CLIENT_ID: ${cf:${self:service}-${self:provider.stage}.UserPoolClientId}

I tried putting these into the env.yml but that didn’t work:

Trying to request a non exported variable from CloudFormation. Stack name: “XXXX-alpha” Requested variable: “UserPoolId”.

I tried using custom instead of environment and it deployed but the Lambda functions no longer had access to the variables.

So how can I mix these two together?

Thank you so much!

The solution so far seems to be declare them in the function separately:

functions:
  myFunction1:
    handler: src/index.js
    environment:
      COGNITO_USER_POOL_ID: !Ref QNABUserPool
      COGNITO_USER_POOL_CLIENT_ID: !Ref QNABUserPoolClient

Suggested here was some ways to avoid putting it into every function: