You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 9, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+49-1Lines changed: 49 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -604,7 +604,7 @@ resources:
604
604
hello: world
605
605
```
606
606
607
-
*Explicit packages support the following properties: `parameters`, `annotations` and `shared`.*
607
+
*Explicit packages support the following properties: `parameters`, `annotations`, `services` and `shared`.*
608
608
609
609
### Binding Packages
610
610
@@ -627,6 +627,50 @@ resources:
627
627
628
628
For more details on package binding, please see the documentation [here](https://github.com/apache/incubator-openwhisk/blob/master/docs/packages.md#creating-and-using-package-bindings).
629
629
630
+
## Binding Services (IBM Cloud Functions)
631
+
632
+
***This feature requires the [IBM Cloud CLI](https://console.bluemix.net/docs/cli/reference/bluemix_cli/download_cli.html#download_install) and [IBM Cloud Functions plugin](https://console.bluemix.net/openwhisk/learn/cli) to be installed.***
633
+
634
+
IBM Cloud Functions supports [automatic binding of service credentials](https://console.bluemix.net/docs/openwhisk/binding_services.html#binding_services) to actions using the CLI.
635
+
636
+
Bound service credentials will be passed as the `__bx_creds` parameter in the invocation parameters.
637
+
638
+
This feature is also available through the `serverless.yaml` file using the `bind` property for each function.
639
+
640
+
```yaml
641
+
functions:
642
+
my_function:
643
+
handler: file_name.handler
644
+
bind:
645
+
- service:
646
+
name: cloud-object-storage
647
+
instance: my-cos-storage
648
+
```
649
+
650
+
The `service` configuration supports the following properties.
651
+
652
+
- `name`: identifier for the cloud service
653
+
- `instance`: instance name for service (*optional*)
654
+
- `key`: key name for instance and service (*optional*)
655
+
656
+
*If the `instance` or `key` properties are missing, the first available instance and key found will be used.*
657
+
658
+
Binding services removes the need to manually create default parameters for service keys from platform services.
659
+
660
+
More details on binding service credentials to actions can be found in the [official documentation](https://console.bluemix.net/docs/openwhisk/binding_services.html#binding_services) and [this blog post](http://jamesthom.as/blog/2018/06/05/binding-iam-services-to-ibm-cloud-functions/).
661
+
662
+
Packages defined in the `resources` section can bind services using the same configuration properties.
663
+
664
+
```yaml
665
+
resources:
666
+
packages:
667
+
myPackage:
668
+
bind:
669
+
- service:
670
+
name: cloud-object-storage
671
+
instance: my-cos-storage
672
+
```
673
+
630
674
## Runtime Configuration Properties
631
675
632
676
The following OpenWhisk configuration properties are supported for functions defined in
This plugins compiles the packages in `serverless.yaml` to corresponding [OpenWhisk Packages](https://github.com/openwhisk/openwhisk/blob/master/docs/packages.md)
4
-
definitions.
3
+
This plugin binds IBM Cloud platform service credentials to actions and packages in `serverless.yaml`.
5
4
6
5
## How it works
7
6
8
-
`Compile Packages` hooks into the [`package:compileEvents`](/lib/plugins/deploy) lifecycle.
7
+
`Compile Service Bindings` hooks into the [`package:compileEvents`](/lib/plugins/deploy) lifecycle.
9
8
10
-
It loops over all packages which are defined in `serverless.yaml`.
9
+
***This feature requires the [IBM Cloud CLI](https://console.bluemix.net/docs/cli/reference/bluemix_cli/download_cli.html#download_install) and [IBM Cloud Functions plugin](https://console.bluemix.net/openwhisk/learn/cli) to be installed.***
11
10
12
-
### Implicit Packages
11
+
IBM Cloud Functions supports [automatic binding of service credentials](https://console.bluemix.net/docs/openwhisk/binding_services.html#binding_services) to actions using the CLI.
13
12
14
-
Actions can be assigned to packages by setting the function `name` with a package reference.
13
+
Bound service credentials will be passed as the `__bx_creds` parameter in the invocation parameters.
14
+
15
+
This feature is also available through the `serverless.yaml` file using the `bind` property for each function.
15
16
16
17
```yaml
17
18
functions:
18
-
foo:
19
-
handler: handler.foo
20
-
name: "myPackage/foo"
21
-
bar:
22
-
handler: handler.bar
23
-
name: "myPackage/bar"
19
+
my_function:
20
+
handler: file_name.handler
21
+
bind:
22
+
- service:
23
+
name: cloud-object-storage
24
+
instance: my-cos-storage
24
25
```
25
26
26
-
In this example, two new actions (`foo` & `bar`) will be created using the `myPackage` package.
27
+
The `service` configuration supports the following properties.
27
28
28
-
Packages which do not exist will be automatically created during deployments. When using the `remove` command, any packages referenced in the `serverless.yml` will be deleted.
29
+
- `name`: identifier for the cloud service
30
+
- `instance`: instance name for service (*optional*)
31
+
- `key`: key name for instance and service (*optional*)
29
32
30
-
### Explicit Packages
33
+
*If the `instance` or `key` properties are missing, the first available instance and key found will be used.*
31
34
32
-
Packages can also be defined explicitly to set shared configuration parameters. Default package parameters are merged into event parameters for each invocation.
35
+
Binding services removes the need to manually create default parameters for service keys from platform services.
33
36
34
-
```yaml
35
-
functions:
36
-
foo:
37
-
handler: handler.foo
38
-
name: "myPackage/foo"
39
-
40
-
resources:
41
-
packages:
42
-
myPackage:
43
-
parameters:
44
-
hello: world
45
-
```
37
+
More details on binding service credentials to actions can be found in the [official documentation](https://console.bluemix.net/docs/openwhisk/binding_services.html#binding_services) and [this blog post](http://jamesthom.as/blog/2018/06/05/binding-iam-services-to-ibm-cloud-functions/).
46
38
47
-
### Binding Packages
48
-
49
-
OpenWhisk also supports "binding" external packages into your workspace. Bound packages can have default parameters set for shared actions.
50
-
51
-
For example, binding the `/whisk.system/cloudant` package into a new package allows you to set default values for the `username`, `password` and `dbname` properties. Actions from this package can then be invoked with having to pass these parameters in.
52
-
53
-
Define packages explicitly with a `binding` parameter to use this behaviour.
39
+
Packages defined in the `resources` section can bind services using the same configuration properties.
54
40
55
41
```yaml
56
42
resources:
57
43
packages:
58
-
mySamples:
59
-
binding: /whisk.system/cloudant
60
-
parameters:
61
-
username: bernie
62
-
password: sanders
63
-
dbname: vermont
64
-
```
65
-
66
-
For more details on package binding, please see the documentation [here](https://github.com/apache/incubator-openwhisk/blob/master/docs/packages.md#creating-and-using-package-bindings).
0 commit comments