serverless / serverless-openwhisk

Adds Apache OpenWhisk support to the Serverless Framework!
http://openwhisk.org/
MIT License
143 stars 46 forks source link

Support multiple stages #72

Closed maxfrigge closed 7 years ago

maxfrigge commented 7 years ago

I cannot figure a way to deploy to multiple stages/environments. If I am not mistaken, there is stage property for AWS that takes care of this.

What I would like to achieve are two API endpoints to point at different versions of the same handler - e.g. staging and production. I tried adding a prefix to the http event route, but it gets overwritten each time a function with the same name is deployed.

Is this currently not supported or am I am missing something?

jthomas commented 7 years ago

Hello @maxfrigge, let me try this out and see what's going wrong...

OpenWhisk doesn't have a built-in concept of "stages" like AWS Lambda. I've chosen to simulate this behaviour by putting the stage in the function name.

Can you provide a sample serverless.yml to help me understand how this would work on Lambda?

jthomas commented 7 years ago

I've been experimenting. Is what you're looking for?

service: stage-apis

provider:
   name: openwhisk

functions:
  hello:
    handler: handler.hello
    events:
       - http: GET /api/${opt:stage}

plugins:
  - serverless-openwhisk

If I type serverless deploy -s prod|dev I get different functions with separate API endpoints.

maxfrigge commented 7 years ago

@jthomas this totally works! Cheers!

Having it in the function name didn't affect the API Endpoint.

jthomas commented 7 years ago

Hurrah! Great 😎