Use variable in variable

I have deployed a severless stack, its cloudformation stack name is serverless-apigateway-dev , the last part is the environment name depend on which environment I deployed. The name format is ${self:service}-${opt:stage, self:provider.stage}

This cloudformation stack has several outputs, for example, one of them is a dynamodb name: serverless-apigateway-dev-todos

Now, I am working on the second serverless stack, which need to refer the variable in the first one.

According serverless variables’ reference cloudformation outputs , I can use DYNAMODB_TABLE: ${cf:serverless-apigateway-dev.serverless-apigateway-dev-todos} to get the dynamodb name. But I don’t want to hard code the environment in it.

What should I do? I need something work like this:

DYNAMODB_TABLE:${cf:${self:service}-${opt:stage, self:provider.stage}.${self:service}-${opt:stage, self:provider.stage}-todos}`

Updates

Seems Nesting Variable References supports this feature, let me try it