#aws-lambda #resource #cloudformation #powered #creation #event #facilitate

cfn-custom-resource

A Rust create to facilitate the creation of Rust Lambda Powered Custom Resources

1 unstable release

0.1.1 Jul 11, 2020
0.1.0 Jul 11, 2020

#2 in #cloudformation

MIT/Apache

14KB
113 lines

Rust cfn-custom-resource

A Rust create to facilate the creation of Rust Lambda Powered Custom Resources for AWS Cloudformation. It does not cast an opinion on which aws lambda custom runtime that the function is executing in.

use cfn_custom_resource::CustomResourceEvent;
use serde::Deserialize;
#[derive(Debug, Deserialize)]
#[serde(rename_all = "PascalCase")]
struct MyParameters {
    value_one: i64,
    value_two: i64,
}
async fn my_handler_func(event: CustomResourceEvent<MyParameters>) {
    match event {
        CustomResourceEvent::Create(data) => {
            println!(
                "{}",
                data.resource_properties.value_one + data.resource_properties.value_two
            );
            data.respond_with_success("all done")
                .finish()
                .await
                .unwrap();
        }
        CustomResourceEvent::Update(data) => {
            println!("got an update");
            data.respond_with_success("all done")
                .finish()
                .await
                .unwrap();
        }
        CustomResourceEvent::Delete(data) => {
            println!("got a delete");
            data.respond_with_success("all done")
                .finish()
                .await
                .unwrap();
        }
    }
}

Dependencies

~3.5–8MB
~188K SLoC