diff --git a/Makefile b/Makefile index f66ee1fd..ecfd7623 100644 --- a/Makefile +++ b/Makefile @@ -101,6 +101,7 @@ check-event-features: cargo test --package aws_lambda_events --no-default-features --features rabbitmq cargo test --package aws_lambda_events --no-default-features --features s3 cargo test --package aws_lambda_events --no-default-features --features s3_batch_job + cargo test --package aws_lambda_events --no-default-features --features secretsmanager cargo test --package aws_lambda_events --no-default-features --features ses cargo test --package aws_lambda_events --no-default-features --features sns cargo test --package aws_lambda_events --no-default-features --features sqs diff --git a/lambda-events/Cargo.toml b/lambda-events/Cargo.toml index 894b236f..c6556b64 100644 --- a/lambda-events/Cargo.toml +++ b/lambda-events/Cargo.toml @@ -75,6 +75,7 @@ default = [ "s3", "s3_batch_job", "ses", + "secretsmanager", "sns", "sqs", "streams", @@ -119,6 +120,7 @@ lex = [] rabbitmq = [] s3 = ["bytes", "chrono", "http", "http-body", "http-serde"] s3_batch_job = ["s3"] +secretsmanager = [] ses = ["chrono"] sns = ["chrono", "serde_with"] sqs = ["serde_with"] diff --git a/lambda-events/src/event/mod.rs b/lambda-events/src/event/mod.rs index ea0ca7df..d63acc4d 100644 --- a/lambda-events/src/event/mod.rs +++ b/lambda-events/src/event/mod.rs @@ -133,6 +133,10 @@ pub mod rabbitmq; #[cfg(feature = "s3")] pub mod s3; +/// AWS Lambda event definitions for secretsmanager. +#[cfg(feature = "secretsmanager")] +pub mod secretsmanager; + /// AWS Lambda event definitions for ses. #[cfg(feature = "ses")] pub mod ses; diff --git a/lambda-events/src/event/secretsmanager/mod.rs b/lambda-events/src/event/secretsmanager/mod.rs new file mode 100644 index 00000000..3ed8d238 --- /dev/null +++ b/lambda-events/src/event/secretsmanager/mod.rs @@ -0,0 +1,24 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)] +#[serde(rename_all = "PascalCase")] +pub struct SecretsManagerSecretRotationEvent { + pub step: String, + pub secret_id: String, + pub client_request_token: String, +} + +#[cfg(test)] +mod test { + use super::*; + + #[test] + #[cfg(feature = "secretsmanager")] + fn example_secretsmanager_secret_rotation_event() { + let data = include_bytes!("../../fixtures/example-secretsmanager-secret-rotation-event.json"); + let parsed: SecretsManagerSecretRotationEvent = serde_json::from_slice(data).unwrap(); + let output: String = serde_json::to_string(&parsed).unwrap(); + let reparsed: SecretsManagerSecretRotationEvent = serde_json::from_slice(output.as_bytes()).unwrap(); + assert_eq!(parsed, reparsed); + } +} diff --git a/lambda-events/src/fixtures/example-secretsmanager-secret-rotation-event.json b/lambda-events/src/fixtures/example-secretsmanager-secret-rotation-event.json new file mode 100644 index 00000000..f137ddbc --- /dev/null +++ b/lambda-events/src/fixtures/example-secretsmanager-secret-rotation-event.json @@ -0,0 +1,5 @@ +{ + "Step": "createSecret", + "SecretId": "arn:aws:secretsmanager:us-east-1:111122223333:secret:id-ABCD1E", + "ClientRequestToken": "1ab23456-cde7-8912-34fg-h56i78j9k12l" +} diff --git a/lambda-events/src/lib.rs b/lambda-events/src/lib.rs index 4fd294e6..e21cdc13 100644 --- a/lambda-events/src/lib.rs +++ b/lambda-events/src/lib.rs @@ -153,6 +153,10 @@ pub use event::s3; #[cfg(feature = "s3")] pub use event::s3::batch_job as s3_batch_job; +/// AWS Lambda event definitions for secretsmanager. +#[cfg(feature = "secretsmanager")] +pub use event::secretsmanager; + /// AWS Lambda event definitions for ses. #[cfg(feature = "ses")] pub use event::ses;