Using Stages for API Versioning

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/

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.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!

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?

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

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