title: How to access environment variables and pass to Lambda function using useDotenv: true option in serverless.yml?
body: <p>I am trying to pass environment variables to my Lambda function in serverless.yml (version 2.32.0) but I am not sure the way of doing it. The doucmentaiton: <a href="https://www.serverless.com/framework/docs/environment-variables/" rel="nofollow noreferrer">https://www.serverless.com/framework/docs/environment-variables/</a> doesn't mention how to. Right now, I am using the <code>useDotenv: true</code> option and then trying to access the environment variables by <code>${process.env.ENV1}</code> but it is not working. Below is my <code>serverless.yml</code> file:</p>
  <p>serverless.yml</p>
  <pre class="lang-yaml prettyprint-override"><code>service: service-name
  frameworkVersion: &quot;2.32.0&quot;
  useDotenv: true
  
  provider:
    name: aws
    versionFunctions: false
    runtime: nodejs12.x
    region: &lt;region&gt;
    stage: dev
    profile: default
  
  functions:
    function-name:
      handler: handler
      timeout: 120
      environment:
        ENV1: ${process.env.ENV1}
        ENV2: ${process.env.ENV2}
        ENV3: ${process.env.ENV3}
  </code></pre>
  <p>I am getting no errors or warning when I run <code>sls deploy</code> but the environment variables are not being uploaded. How would I be able to do it?</p>