# Overwriting environment variables when invoking local function

**URL:** <https://forum.serverless.com/t/overwriting-environment-variables-when-invoking-local-function/4916>\
**Category:** Serverless Framework\
**Created:** [June 29, 2018, 2:59pm UTC](https://forum.serverless.com/t/overwriting-environment-variables-when-invoking-local-function/4916 "2018-06-29T14:59:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![RudolfVonKrugstein](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/rudolfvonkrugstein/32/1891_2.png) [@RudolfVonKrugstein](https://forum.serverless.com/u/RudolfVonKrugstein)\
**Post date:** [June 29, 2018, 2:59pm UTC](https://forum.serverless.com/t/overwriting-environment-variables-when-invoking-local-function/4916/1 "2018-06-29T14:59:01Z")

</div>

Hey,

I am setting environment variables in `serverless.yml` like this:

```auto
  environment:
    DYNAMODB_TABLE:
      Ref: DynamodDBTable

```

That does not work with local function invocation, because than the variable is set to: `[object Object]`.

Can I somehow overwrite the environment variables when invoking lambda local?

---

<div class="post-metadata">

**Author:** ![jeremydaly](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/jeremydaly/32/2104_2.png) [@jeremydaly](https://forum.serverless.com/u/jeremydaly)\
**Post date:** [July 2, 2018, 4:24pm UTC](https://forum.serverless.com/t/overwriting-environment-variables-when-invoking-local-function/4916/2 "2018-07-02T16:24:45Z")

</div>

Local references don’t work like that because they require a lookup to the CloudFormation stack. I wrote a post about this that should help you accomplish what you want:

> **[How To: Manage Serverless Environment Variables Per Stage - Jeremy Daly](https://www.jeremydaly.com/how-to-manage-serverless-environment-variables-per-stage/)**
>
> Using STAGES and ENVIRONMENT variables together in your Serverless project can create a really powerful workflow for you and your development team. Learn how to properly configure your environments per stage.
