# Use variable in variable

**URL:** <https://forum.serverless.com/t/use-variable-in-variable/2977>\
**Category:** Serverless Framework\
**Created:** [October 27, 2017, 10:12am UTC](https://forum.serverless.com/t/use-variable-in-variable/2977 "2017-10-27T10:12:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bill](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/bill/32/1072_2.png) [@bill](https://forum.serverless.com/u/bill)\
**Post date:** [October 27, 2017, 10:12am UTC](https://forum.serverless.com/t/use-variable-in-variable/2977/1 "2017-10-27T10:12:00Z")

</div>

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](http://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](https://serverless.com/framework/docs/providers/aws/guide/variables#nesting-variable-references) supports this feature, let me try it
