# Deploy function does not work entirely

**URL:** <https://forum.serverless.com/t/deploy-function-does-not-work-entirely/4635>\
**Category:** Serverless Framework\
**Created:** [June 1, 2018, 5:49pm UTC](https://forum.serverless.com/t/deploy-function-does-not-work-entirely/4635 "2018-06-01T17:49:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![diegol](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/diegol/32/2036_2.png) [@diegol](https://forum.serverless.com/u/diegol)\
**Post date:** [June 1, 2018, 5:49pm UTC](https://forum.serverless.com/t/deploy-function-does-not-work-entirely/4635/1 "2018-06-01T17:49:49Z")

</div>

I’m using serverless - Lambda (alias and versions) - API gateway

When I change my code and use sls deploy and test my function in postman or browser It gets updated and I can see the change in the response (postman or browser).

BUT when I change my code (added the word captain after hello) and use:

> serverless deploy function -f myFunction

The change is **not** shown in the response (postman). but you can see the change in lambda inline preview and it is also shown when I test it in API gateway under resources option (see image below).

 ![err3](https://canada1.discourse-cdn.com/flex036/uploads/serverless/original/2X/a/a7554b0924fd9cfd5b34c03819b3124619f1e11b.PNG)

If I execute sls deploy then the change is shown in the response.

Is there a way to reflect my changes when just deploying a single function?

Thanks.

---

<div class="post-metadata">

**Author:** ![buggy](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/buggy/32/177_2.png) [@buggy](https://forum.serverless.com/u/buggy)\
**Post date:** [June 2, 2018, 1:31am UTC](https://forum.serverless.com/t/deploy-function-does-not-work-entirely/4635/2 "2018-06-02T01:31:29Z")

</div>

`serverless deploy function` only updates the code for $LATEST. You need to use the full `serverless deploy` if you’re updating the CloudFormation template too.

> Is there a way to reflect my changes when just deploying a single function?

Stop using aliases and versions

---

<div class="post-metadata">

**Author:** ![diegol](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/diegol/32/2036_2.png) [@diegol](https://forum.serverless.com/u/diegol)\
**Post date:** [June 2, 2018, 1:38am UTC](https://forum.serverless.com/t/deploy-function-does-not-work-entirely/4635/3 "2018-06-02T01:38:43Z")

</div>

I was using them to mantain a dev and prod version of my app. Now I’d just change de serverless.yml stage value to deploy my code and test right? It’s a little scary what if by mistake prod stage is deployed and I haven’t test the app yet.

---

<div class="post-metadata">

**Author:** ![buggy](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/buggy/32/177_2.png) [@buggy](https://forum.serverless.com/u/buggy)\
**Post date:** [June 2, 2018, 2:04am UTC](https://forum.serverless.com/t/deploy-function-does-not-work-entirely/4635/4 "2018-06-02T02:04:23Z")

</div>

What you probably want are Serverless Framework stages. These are different to API Gateway stages or Lambda aliases because they deploy a complete copy of the environment. This allows you to safely test everything in “test” before deploying to “prod”.

---

<div class="post-metadata">

**Author:** ![diegol](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/diegol/32/2036_2.png) [@diegol](https://forum.serverless.com/u/diegol)\
**Post date:** [June 2, 2018, 2:20am UTC](https://forum.serverless.com/t/deploy-function-does-not-work-entirely/4635/5 "2018-06-02T02:20:10Z")

</div>

> [@buggy](#):
>
> Serverless Framework stages

I mention using the stage parameter in the .yml file that’d do it right?  
Is this [article](https://serverless-stack.com/chapters/stages-in-serverless-framework.html) correct?

---

<div class="post-metadata">

**Author:** ![buggy](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/buggy/32/177_2.png) [@buggy](https://forum.serverless.com/u/buggy)\
**Post date:** [June 4, 2018, 12:00am UTC](https://forum.serverless.com/t/deploy-function-does-not-work-entirely/4635/6 "2018-06-04T00:00:18Z")

</div>

You can also set it during deployment with the `-s` or `--stage` command line option. I typically don’t set the stage in the `provider` section. In the custom section I add:

```auto
custom:
  stage: ${opt:stage, self:provider.stage}

```

Then reference `${custom.stage}` anywhere I need the current stage in my `serverless.yml` file. There are variations on this including setting the stage in the provider setting to `${opt:stage, "dev"}`
