title: Set environment variables from string of key/value pairs
body: <p>I'm using AWS Secrets Manager to pull some environment variables during the deployment process for a React CloudFront Web App. I have not written a ton of javascript - and I'm trying to figure out the best way to extract values from my string of 'secrets' and set them as environment variables.</p>
  
  <p>For some context, I'm able to hook into the AWS-SDK just fine and retrieve my secrets - they look like this:</p>
  
  <pre><code>console.log(secret)
  &gt; {"JOE":"https://joe.com","MIKE":"http://mike.com"}
  </code></pre>
  
  <p>The first surprise came when I decided to check the type of my secret and came to find out javascript is evaluating it as a string:</p>
  
  <pre><code>console.log(typeof secret);
  &gt; string
  </code></pre>
  
  <p>Since I now know I'm working with a string, I'm attempting to find the most efficient way to parse this 'string' (though it looks like a dictionary to my python eyes) and set each key/pair value within the string as environment variables.</p>
  
  <p>The first I tried was the 'modules.export' method - I did something like:</p>
  
  <pre><code>module.exports = secret;
  
  if(process.env.JOE) {
      console.log('It is set!');
  }
  else {
      console.log('No set!');
  }
  </code></pre>
  
  <p>Of course, this was too good to be true - and did not appear to work as I'd hoped.</p>
  
  <p>The next thing I tried was simply to try and index the string and see what it might return:</p>
  
  <pre><code>console.log(secret["JOE"]);
  &gt; undefined
  </code></pre>
  
  <p>No luck there.</p>
  
  <p>I have tried a variety of other simple builtin javascript methods but I'm not seeming to make any progress. Am I think correctly that I should first load this into a dictionary, then possibly use modules.export to set each key/pair in the dict as environment variables ?</p>