# Fallback Variable Syntax

**URL:** <https://forum.serverless.com/t/fallback-variable-syntax/12456>\
**Category:** Serverless Framework\
**Created:** [September 2, 2020, 12:34pm UTC](https://forum.serverless.com/t/fallback-variable-syntax/12456 "2020-09-02T12:34:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![duskyshelf](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/duskyshelf/32/4547_2.png) [@duskyshelf](https://forum.serverless.com/u/duskyshelf)\
**Post date:** [September 2, 2020, 12:34pm UTC](https://forum.serverless.com/t/fallback-variable-syntax/12456/1 "2020-09-02T12:34:20Z")

</div>

Question on how do variable fallbacks work.

I have the following line:  
`usefulVariable: ${self:custom.envs.${self:custom.environment}.nestedProperty, self:custom.envs.dev.nestedProperty}`

is there a way to refactor and define something like the following:  
`envData: ${self:custom.envs.${self:custom.environment, 'dev'}}`

whilst maintaining the above fallback value?

i.e. if `custom.environment: 'production'` but `production.nestedProperty` is not defined, we can still get `development.nestedProperty`

(obviously I can write something like:  
`usefulVariable: ${self:custom.envData,nestedProperty, self:custom.envs.dev.nestedProperty}`, but this is too similar to the original example and we repeat this pattern many times)
