# Using Stages for API Versioning

**URL:** <https://forum.serverless.com/t/using-stages-for-api-versioning/2265>\
**Category:** Serverless Framework\
**Tags:** aws\
**Created:** [July 10, 2017, 7:13pm UTC](https://forum.serverless.com/t/using-stages-for-api-versioning/2265 "2017-07-10T19:13:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![SinuZ](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@SinuZ](https://forum.serverless.com/u/SinuZ)\
**Post date:** [July 10, 2017, 7:13pm UTC](https://forum.serverless.com/t/using-stages-for-api-versioning/2265/1 "2017-07-10T19:13:14Z")

</div>

Hi,

I try to use different stages as parallel live versions of my API but it does not seem to be possible to use versions as names. So for example I would like to have this:

Dev Version:  
[https://xxx.execute-api.us-east-1.amazonaws.com/dev/](https://xxx.execute-api.us-east-1.amazonaws.com/dev/)

Live Versions:  
[https://xxx.execute-api.us-east-1.amazonaws.com/1.0.0/](https://xxx.execute-api.us-east-1.amazonaws.com/1.0.0/)  
[https://xxx.execute-api.us-east-1.amazonaws.com/1.0.1/](https://xxx.execute-api.us-east-1.amazonaws.com/1.0.1/)  
…

So I set the stage name to `--stage=1.0.0` I get this error:

`The stack service name "MyBackend-1.0.0" is not valid. A service name should only contain alphanumeric (case sensitive) and hyphens. It should start with an alphabetic character and shouldn't exceed 128 characters.`

Ok, how unfortunate I thought, but no problem, I just use hyphens then: `--stage=1-0-0`

Now I get this error:

`An error occurred while provisioning your stack: ApiGatewayDeployment1499712562479 - Stage name only allows a-zA-Z0-9_.`

Well okay, I’ll try `--stage=1_0_0` then:

`The stack service name "MyBackend-1_0_0" is not valid. A service name should only contain alphanumeric (case sensitive) and hyphens. It should start with an alphabetic character and shouldn't exceed 128 characters.`

Right, right… Hm, maybe I just have to live with something like `--stage=100` then?

```
ServerlessError: TypeError: this.getStage(...).toUpperCase is not a function
    at AwsDeploy.BbPromise.bind.then.catch (/usr/local/lib/node_modules/serverless/lib/plugins/aws/deploy/lib/createStack.js:74:15)
    at AwsDeploy.tryCatcher (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:689:18)
    at Async._drainQueue (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:133:16)
    at Async._drainQueues (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:143:10)
    at Immediate.Async.drainQueues (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:800:20)
    at tryOnImmediate (timers.js:762:5)
    at processImmediate [as _immediateCallback] (timers.js:733:5)

```

Ok, now that’s just mean!

So how can I use different stages for versioning if I want to use version numbers as names?

Thank you very much!

---

<div class="post-metadata">

**Author:** ![SinuZ](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@SinuZ](https://forum.serverless.com/u/SinuZ)\
**Post date:** [July 10, 2017, 8:45pm UTC](https://forum.serverless.com/t/using-stages-for-api-versioning/2265/2 "2017-07-10T20:45:35Z")

</div>

Just found out, `--stage=v100` works, I guess because there is at least one character in it.  
Still this is not very nice, there should be at least a separator between major, minor and micro version. Stack service name and stage name seem to contradict each other on anything that is not a character! Any idea?

---

<div class="post-metadata">

**Author:** ![leftclickben](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/leftclickben/32/625_2.png) [@leftclickben](https://forum.serverless.com/u/leftclickben)\
**Post date:** [July 11, 2017, 1:50pm UTC](https://forum.serverless.com/t/using-stages-for-api-versioning/2265/3 "2017-07-11T13:50:16Z")

</div>

Use underscores? `--stage=v1_0_0` – the error message you posted says you can use them (“Stage name only allows a-zA-Z0-9\_.”)

---

<div class="post-metadata">

**Author:** ![leftclickben](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/leftclickben/32/625_2.png) [@leftclickben](https://forum.serverless.com/u/leftclickben)\
**Post date:** [July 11, 2017, 1:51pm UTC](https://forum.serverless.com/t/using-stages-for-api-versioning/2265/4 "2017-07-11T13:51:02Z")

</div>

Sorry I didn’t read properly – you tried that already. Sorry!
