# Using env var on serverless.test.yaml

**URL:** <https://forum.serverless.com/t/using-env-var-on-serverless-test-yaml/11558>\
**Category:** Serverless Framework\
**Tags:** variables\
**Created:** [May 26, 2020, 11:38am UTC](https://forum.serverless.com/t/using-env-var-on-serverless-test-yaml/11558 "2020-05-26T11:38:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![GuyAvraham](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/guyavraham/32/3912_2.png) [@GuyAvraham](https://forum.serverless.com/u/GuyAvraham)\
**Post date:** [May 26, 2020, 11:38am UTC](https://forum.serverless.com/t/using-env-var-on-serverless-test-yaml/11558/1 "2020-05-26T11:38:51Z")

</div>

Hi  
Im successfully using environment variables on my serverless.yaml file with:  
${env:VAR\_NAME}

But,  
This solution doesnt work on serverless.test.yaml. I am testing there apis which are protected with api key.  
Attempt to define that secret x-api-key doesnt work for me (getting FORBIDDEN 403):  
request:  
headers:  
x-api-key: ${env:SLS\_DEV\_API\_KEY}

running from the CLI:  
SLS\_DEV\_API\_KEY=SECRET sls test

If I use the actual key string it works, so I assume I am not reading the environment var correctly.  
Would appreciate your help
