Skip to content

Commit

Permalink
Add SecretsManagerSecretRotationEvent (#811)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdnakt authored Feb 8, 2024
1 parent 9ed543c commit 94b33e8
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions lambda-events/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ default = [
"s3",
"s3_batch_job",
"ses",
"secretsmanager",
"sns",
"sqs",
"streams",
Expand Down Expand Up @@ -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"]
Expand Down
4 changes: 4 additions & 0 deletions lambda-events/src/event/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
24 changes: 24 additions & 0 deletions lambda-events/src/event/secretsmanager/mod.rs
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"Step": "createSecret",
"SecretId": "arn:aws:secretsmanager:us-east-1:111122223333:secret:id-ABCD1E",
"ClientRequestToken": "1ab23456-cde7-8912-34fg-h56i78j9k12l"
}
4 changes: 4 additions & 0 deletions lambda-events/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 94b33e8

Please sign in to comment.