Skip to content

Commit 08ff4c5

Browse files
authored
Merge pull request #20 from gunnargrosch/develop
Develop
2 parents 1e548cd + 6551bc9 commit 08ff4c5

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ Inspired by Yan Cui's articles on latency injection for AWS Lambda (https://hack
8787

8888
## Changelog
8989

90+
### 2020-10-26 v0.4.1
91+
92+
* Made AppConfig Lambda extension port configurable using environment variable.
93+
9094
### 2020-10-25 v0.4.0
9195

9296
* 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.

lib/failure.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ async function getConfig () {
1111
}
1212
if (process.env.FAILURE_APPCONFIG_CONFIGURATION) {
1313
try {
14-
const url = 'http://localhost:2772/applications/' + process.env.FAILURE_APPCONFIG_APPLICATION + '/environments/' + process.env.FAILURE_APPCONFIG_ENVIRONMENT + '/configurations/' + process.env.FAILURE_APPCONFIG_CONFIGURATION
14+
if (process.env.AWS_APPCONFIG_EXTENSION_HTTP_PORT) {
15+
var appconfigPort = process.env.AWS_APPCONFIG_EXTENSION_HTTP_PORT
16+
} else {
17+
var appconfigPort = 2772
18+
}
19+
const url = 'http://localhost:' + appconfigPort + '/applications/' + process.env.FAILURE_APPCONFIG_APPLICATION + '/environments/' + process.env.FAILURE_APPCONFIG_ENVIRONMENT + '/configurations/' + process.env.FAILURE_APPCONFIG_CONFIGURATION
1520
const response = await fetch(url)
1621
const json = await response.json()
1722
return json
@@ -38,8 +43,6 @@ async function getConfig () {
3843
var injectFailure = function (fn) {
3944
return async function () {
4045
try {
41-
// let configResponse = await getConfig()
42-
// let config = JSON.parse(configResponse)
4346
let config = await getConfig()
4447
if (config.isEnabled === true && Math.random() < config.rate) {
4548
if (config.failureMode === 'latency') {

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "failure-lambda",
3-
"version": "0.4.0",
3+
"version": "0.4.1",
44
"description": "Module for failure injection into AWS Lambda",
55
"main": "./lib/failure.js",
66
"scripts": {

0 commit comments

Comments
 (0)