Serverless Config Service Plugin
The Serverless Config Service Plugin is a NPM package used within C1. This Serverless plugin allows you to retrieve values and populate those values as environment variables from config service/redis commander within a serverless.yaml file.
Installation
First install the plugin using npm
npm install maskdata --save-dev
npm install redis --save-dev
npm install serverless-cfg-service-plugin --save-dev
Then inside your project's serverless.yml
file add the following to the plugins section. You should change the redis url & port to match your build environment.
provider:
environment:
CONFIG_SERVICE_REDIS_URL: updateme
CONFIG_SERVICE_REDIS_PORT: updateme
CONFIG_SERVICE_JSON_KEY: ${self:custom.rootServiceName}/application-dev.json/<updateme>
CONFIG_SERVICE_PROPERTIES_KEY: ${self:custom.rootServiceName}/application-dev.properties/<updateme>
plugins:
- serverless-cfg-service-plugin
To reference a config service value, you must prefix it with ${cfg(param1, param2, param3):redisKey}, and pass 3 params to this custom variable for retrieving values from config service, the params' order should be [rootServiceName, redisUrl, redisPort]. For example:
provider:
environment:
SOME_VARIABLE: ${cfg:${self:provider.environment.CONFIG_SERVICE_PROPERTIES_KEY}}
custom:
rootServiceName: 'updateme'