serverless / serverless-openwhisk

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

Can I setup IBM Cloud Object Storage in my serverless.yml #124

Closed chearmstrong closed 6 years ago

chearmstrong commented 6 years ago

Hi.

I have a project that I need to deploy to IBM Cloud Functions (OpenWhisk) - is it possible to setup IBM Cloud Object Storage (IBM's version of S3) in my serverless.yml file, like I would do if I was deploying to AWS?

Thanks in advance.

jthomas commented 6 years ago

Hello @chearmstrong, thanks for asking about this.

short answer: this isn't possible (at the moment). workarounds are available (see below).

here's the long answer...

The Serverless Framework uses Cloud Formation to deploy resources listed in the YAML file to AWS. Cloud Formation can define Lambda functions but also other AWS resources like S3. The OpenWhisk provider plugin for The Serverless Framework uses the OpenWhisk platform APIs to create serverless resources, rather than an IBM Cloud specific service. IBM Cloud does not have a direct equivalent to AWS Cloud Formation. This means the OpenWhisk plugin can only define OpenWhisk-related resources.

If you need to set up other IBM Cloud services, like Cloud Object Storage, this will have to happen outside the framework. Service credentials created externally can be imported and stored as default parameters on actions.

I wrote a blog post about manually doing this recently: http://jamesthom.as/blog/2018/06/05/binding-iam-services-to-ibm-cloud-functions/

provsioning services

IBM Cloud services can either be provisioned through the web console, using the CLI or using an "infrastructure-as-code" tool. IBM Cloud has chosen terraform as the official "infrastructure as code" solution for IBM Cloud and provides an external plugin.

binding credentials to actions in serverless.yml

Service credentials are normally stored as default parameters on actions. Default parameters can be defined in the serverless.yml. Rather than keeping raw credentials values in the YAML file (and having to check them into source repositories), I would keep the variables in a local file and reference those values using the framework's variables feature. These values will be automatically pulled in at deployment time but don't need to be checked into the code repository.

See an example of this approach here.

improving the developer experience

I know this is a pain for developers and want to provide a better "developer experience" for this common issue.

I've got an issue open to make it easier to bind service credentials to actions. This will automate the process of binding credentials to actions with needing you to manually create a temporary local file. It should be included in the next release, which will be available in a week or two.

chearmstrong commented 6 years ago

Thanks for great response - I'll check out those examples you mentioned.

jthomas commented 6 years ago

@chearmstrong I've now added the ability to bind to existing services more easily: https://github.com/serverless/serverless-openwhisk#binding-services-ibm-cloud-functions

Will be available in the next release.

chearmstrong commented 6 years ago

@jthomas Awesome - thanks for the update! 👍