Chaos Extension - Seamless, Universal & Lightning-Fast
The lambda-chaos-extension
allows you to inject faults into Lambda functions without modifying the function code. Unlike previous chaos implementations that required tight coupling with the Lambda runtime, this extension is runtime-agnostic. It can operate with any runtime that utilizes Amazon Linux 2. Currently, the supported runtimes include:
- Node.js 18
- Node.js 16
- Node.js 14
- Python 3.10
- Python 3.9
- Python 3.8
- Java 17
- Java 11
- Java 8
- .NET 6
- Ruby 3.2
- Ruby 2.7
- provided.al2
The extension can inject two types of faults based on the configuration:
- Induce latency.
- Modify function response.
Main Benefits
-
🔄 Seamless Integration: Requires no code changes. Simply plug and play! -
🌐 Universal Compatibility: Completely agnostic to the Lambda runtime. Flexibility at its finest! - 🚀 Blazing Fast: Written in Rust for peak performance. Zero impact on your Lambda's behavior when turned off, ensuring smooth operations.
Configuration
Control the extension via environment variables:
Latency Fault
CHAOS_EXTENSION__LAMBDA__ENABLE_LATENCY
- Enables latency fault injection. Acceptstrue
orfalse
. Default isfalse
.CHAOS_EXTENSION__LAMBDA__LATENCY_VALUE
- Specifies the latency duration (in seconds) to introduce. Default is900
seconds.CHAOS_EXTENSION__LAMBDA__LATENCY_PROBABILITY
- A probability value between 0 and 1 that determines the likelihood of fault injection. Default is0.9
.
Response Fault
CHAOS_EXTENSION__RESPONSE__ENABLE_CHANGE_RESPONSE_BODY
- Enables response fault injection. Acceptstrue
orfalse
. Default isfalse
.CHAOS_EXTENSION__RESPONSE__DEFAULT_RESPONSE
- Specifies the response to return in stringified JSON format. Default is:
{
"statusCode": 500,
"body": "hello, Chaos!!!"
}
CHAOS_EXTENSION__RESPONSE__CHANGE_RESPONSE_PROBABILITY
- A probability value between 0 and 1 that determines the likelihood of fault injection. Default is0.9
.
Deployment
The chaos extension is publicly available as a layer. For the latest versions of the layer, refer to LAYERS.md. Incorporate the layer using the AWS Console, or your preferred IAC solution. Additionally, when incorporating the layer, remember to set an environment variable in your Lambda. This variable should be named AWS_LAMBDA_EXEC_WRAPPER
and have /opt/bootstrap
as its value.
See the AWS SAM usage example in the examples
directory.
Running Locally
Unit testing
- Utilize
cargo
for build and test management. - We employ
just
as a command runner. - Execute
just gate
to run all checks locally.
Deployment for testing
- Use
just deploy-debug-extension
to deploy a debug version of the extension tous-east-1
usingx86_64-unknown-linux-gnu
as target. - Use
just deploy-release-extension
to deploy a release version of the extension tous-east-1
usingx86_64-unknown-linux-gnu
as target.
These just
tasks also accept arguments to change the region and the target. Use just --list
to get more details about the various deploy options.
Logs
- Use
RUST_LOG
environment variable to change the extension log level. Default iserror
.
Contributing
For contribution guidelines, see our CONTRIBUTION page.