Skip to content

Commit

Permalink
Merge pull request #19 from gunnargrosch/feature-appconfigport
Browse files Browse the repository at this point in the history
Feature appconfigport
  • Loading branch information
gunnargrosch authored Oct 26, 2020
2 parents 81ab22b + f67e6a1 commit 6551bc9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 6 additions & 3 deletions lib/failure.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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') {
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit 6551bc9

Please sign in to comment.