restApiId and restApiRootResourceId per stage

Hi all!

I am trying to configure a restApiId and a restApiRootResourceId per stage as below, these are configured in custom.yml and referenced from each serverless.yml file. When I start deploying I get the error: Value of property Variables must be an object with String (or simple type) properties.

Please find my code below, any help is appreciated, thanks in advance

serverless.yml

apiGateway:
    restApiId: ${self:custom.restApiId.${self:custom.stage}}
    restApiRootResourceId: ${self:custom.restApiRootResourceId.${self:custom.stage}}
serviceName: xxxx

custom.yml

restApiId:
  dev: xxxx
  test: xxxx
  prod: xxxx
restApiRootResourceId:
  dev: xxxx
  test: xxx
  prod: xxx