caws

Crates.iocaws
lib.rscaws
version0.1.8
sourcesrc
created_at2022-12-30 19:56:39.286929
updated_at2023-01-24 14:38:57.656911
descriptionChaos on AWS Library
homepage
repositoryhttps://github.com/dawsonfi/caws
max_upload_size
id748047
size58,589
Dawson Freitas Israel (dawsonfi)

documentation

https://docs.rs/caws

README

Caws

Chaos on AWS Library and Lambda

Usage

Rust

  • Create a new Rust project with cargo new --bin PROJECT_NAME
  • Add the necessary dependencies to you Cargo.toml:
[dependencies]
tokio = { version = "1.23.0", features = ["full"] }
serde_json = "1.0.91"
lambda_runtime = "0.7.2"
caws = "1.0.0"
  • Change main.rs to the following code:
use caws::{DestructionResults, Key, Kraken};
use lambda_runtime::{service_fn, Error, LambdaEvent};
use serde_json::{from_value, to_value, Value};

#[tokio::main]
async fn main() -> Result<(), Error> {
    lambda_runtime::run(service_fn(func)).await?;
    Ok(())
}

async fn func(event: LambdaEvent<Value>) -> Result<Value, Error> {
    let event = event.payload;
    let key: Key = from_value(event)?;

    let kraken = Kraken::new();
    let destruction_results = kraken.release(key).await?;

    Ok(to_value(DestructionResults {
        execution_status: destruction_results.execution_status,
    })?)
}

  • Build and package your code with: cargo lambda build --release --x86-64 --output-format zip (you might need to install cargo-lambda first)

CDK

  • Add the dependency to your cdk project
"caws-constructs": "^0.1.4",
  • Import the CawsLambda construct:
import { CawsLambda } from 'caws-constructs';
  • Create the Lambda:
new CawsLambda(this, 'lambda-id', {
    functionName: 'function-name',
    brazilPackagePath: 'path/to/bootstrap.zip',
    env: [
        "agents": {
            //Configure here the agents that you want to enable
            "test": ["dummy"]
        }
    ]
})
  • Run cdk deploy to create the lambda and eventbridge schedule
Commit count: 35

cargo fmt