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: