Configuration

Cloud Functions can be used to integrate with external services. Most API's require credentials that need to be stored. These should not be hard-coded into your code. Cloud Functions can be configured using JSON.

The configuration can be created locally by setting the configuration in the context_config.json file in the root of your workspace. There are no requirements on the format, but all configs should be set on the values key, see the example below. This is the preferred place to put your credentials for development.

The context_config.json file is not used if your Cloud Function runs in IXON Cloud. In IXON Cloud you can set the configuration in Admin. The configuration set in Admin is stored encrypted.

πŸ“˜

Make sure you use the same schema locally and in the cloud, or your Cloud Function may not work correctly.

Using the config

The configuration is made available via the FunctionContext. Note that numbers (integers and floats) are parsed as strings. The configuration is accessible via the config field in the context.

{
  "values": {
    "apiApplication": "pubidxxxxxxx"
  }
}
from ixoncdkingress.function.context import FunctionContext

@FunctionContext.expose
def hello_world(context: FunctionContext, **kwargs: Dict[str, str]):
    # prints "pubidxxxxxxx"
    print(context.config.apiApplication)