From 29d3ed13aa34c475ef5c36524502ebe0b62d4f48 Mon Sep 17 00:00:00 2001 From: Gunnar Grosch Date: Mon, 26 Oct 2020 23:57:30 +0100 Subject: [PATCH 1/3] Variable AppConfig extension port --- lib/failure.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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') { From fad8364594aa2e539d925070a8420044a32037a4 Mon Sep 17 00:00:00 2001 From: Gunnar Grosch Date: Mon, 26 Oct 2020 23:08:24 +0000 Subject: [PATCH 2/3] Updated readme --- README.md | 4 ++++ 1 file changed, 4 insertions(+) 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. From f67e6a1929b880882bc91732f09b016c7fb2931d Mon Sep 17 00:00:00 2001 From: Gunnar Grosch Date: Mon, 26 Oct 2020 23:08:29 +0000 Subject: [PATCH 3/3] 0.4.1 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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": {