diff --git a/README.md b/README.md index 435601d..fe48ca9 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,10 @@ Inspired by Yan Cui's articles on latency injection for AWS Lambda (https://hack ## Changelog +### 2020-10-26 v0.4.1 + +* Made AppConfig Lambda extension port configurable using environment variable. + ### 2020-10-25 v0.4.0 * Added optional support for AWS AppConfig, allowing to validate failure configuration, deploy configuration using gradual or non-gradual deploy strategy, monitor deployed configuration with automatical rollback if CloudWatch Alarms is configured, and caching of configuration. diff --git a/lib/failure.js b/lib/failure.js index c5eda90..e5db42e 100644 --- a/lib/failure.js +++ b/lib/failure.js @@ -11,7 +11,12 @@ async function getConfig () { } if (process.env.FAILURE_APPCONFIG_CONFIGURATION) { try { - const url = 'http://localhost:2772/applications/' + process.env.FAILURE_APPCONFIG_APPLICATION + '/environments/' + process.env.FAILURE_APPCONFIG_ENVIRONMENT + '/configurations/' + process.env.FAILURE_APPCONFIG_CONFIGURATION + if (process.env.AWS_APPCONFIG_EXTENSION_HTTP_PORT) { + var appconfigPort = process.env.AWS_APPCONFIG_EXTENSION_HTTP_PORT + } else { + var appconfigPort = 2772 + } + const url = 'http://localhost:' + appconfigPort + '/applications/' + process.env.FAILURE_APPCONFIG_APPLICATION + '/environments/' + process.env.FAILURE_APPCONFIG_ENVIRONMENT + '/configurations/' + process.env.FAILURE_APPCONFIG_CONFIGURATION const response = await fetch(url) const json = await response.json() return json @@ -38,8 +43,6 @@ async function getConfig () { var injectFailure = function (fn) { return async function () { try { - // let configResponse = await getConfig() - // let config = JSON.parse(configResponse) let config = await getConfig() if (config.isEnabled === true && Math.random() < config.rate) { if (config.failureMode === 'latency') { diff --git a/package-lock.json b/package-lock.json index 5b8b1d5..05d47e4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "failure-lambda", - "version": "0.4.0", + "version": "0.4.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 632a0e7..06c4818 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "failure-lambda", - "version": "0.4.0", + "version": "0.4.1", "description": "Module for failure injection into AWS Lambda", "main": "./lib/failure.js", "scripts": {