This example shows how to set input parameter values using environment variables. “hello world” example and shows how fixed values can be supplied to the input parameters of an Action.
It shows how to:
hello_world
’ whose values are set (i.e., bound) from values taken from environment variables.packages: hello_world_package: version: 1.0 license: Apache-2.0 actions: hello_world_env_var_parms: function: src/hello.js inputs: name: $FIRSTNAME place: ${TOWN}, ${COUNTRY}
Set the values for the three environment variables expected by the Action and deploy:
$ FIRSTNAME=Sam TOWN="the Shire" COUNTRY="Middle-earth" wskdeploy -m docs/examples/manifest_hello_world_env_var_parms.yaml
$ wsk action invoke hello_world_package/hello_world_env_var_parms --blocking
The invocation should return an ‘ok’ with a response that includes this result:
"result": { "greeting": "Hello, Sam from the Shire, Middle-earth" },
if we modify the three environment variables to different values, update the action and invoke it again:
$ export FIRSTNAME=Elrond TOWN="Rivendell" COUNTRY="M.E." $ wskdeploy -m docs/examples/manifest_hello_world_env_var_parms.yaml $ wsk action invoke hello_world_package/hello_world_env_var_parms --blocking
the result will reflect the changes to the environment variables:
"result": { "greeting": "Hello, Elrond from Rivendell, M.E." },
In this example:
The manifest file for this example can be found here:
For convenience, the Actions and Parameters grammar can be found here: