title: How to use an environment variable value in another environment variable name and value using dotenv?
body: <p>For my testing framework I'm using <a href="https://github.com/motdotla/dotenv" rel="nofollow noreferrer">dotenv</a> to read and initialize environment variables for different test environments. Now I want to use a specific environment variable value as a part of the value and the name of another environment variables.</p>
  
  <p>So, I set the env var <code>export INSTANCE=1</code> before initializing the env file with <code>dotenv</code>.</p>
  
  <p>This is my env file with all the env vars I want to initialize with <code>dotenv</code>:</p>
  
  <pre><code># INSTANCE as part of env var value
  MY_DOMAIN="http://mypage/"$INSTANCE""
  
  # INSTANCE as part of env var name
  SUBDOMAIN"$INSTANCE"="/mysubdomain"
  </code></pre>
  
  <p>And this metric is also not working:</p>
  
  <pre><code># INSTANCE as part of env var value
  MY_DOMAIN=http://mypage/${INSTANCE}
  
  # INSTANCE as part of env var name
  SUBDOMAIN${INSTANCE}=/mysubdomain
  </code></pre>
  
  <p>This is possible doing it via bash with </p>
  
  <pre><code>export MY_DOMAIN="http://mypage/"$INSTANCE"" SUBDOMAIN"$INSTANCE"="/mysubdomain"
  
  echo $MY_DOMAIN
  http://mypage/1
  
  echo $SUBDOMAIN1
  /mysubdomain
  </code></pre>
  
  <p>But using <code>dotenv</code> it is not working for me. I have the following code:</p>
  
  <pre><code>const dotenv = require("dotenv");
  var result = dotenv.config({ path: '/path/to/my/env/file' });
  
  console.log(result.parsed);
  </code></pre>
  
  <p>The <code>console.log</code> produces the following result:</p>
  
  <pre><code>{
    MY_DOMAIN:'http://mypage/"$INSTANCE"'
  }
  </code></pre>
  
  <p>So, the env var <code>INSTANCE</code> can not be used, the value will be ignored. Are there any solution to solve my issue?</p>