Variable names in Fn::Sub syntax must contain ... error when using outputs and env

I get

The CloudFormation template is invalid: Template error: variable names in Fn::Sub syntax must contain only alphanumeric characters, underscores, periods, and colons

using

custom: groupTableName: ${output::${param:env}::database-service.dbName}

I’ve seen this approach here under Consuming outputs in fullstack-restapi across stages near the bottom

When I try to do sls deploy