aws_lambda_events/event/config/
mod.rs

1use serde::{Deserialize, Serialize};
2#[cfg(feature = "catch-all-fields")]
3use serde_json::Value;
4
5/// `ConfigEvent` contains data from an event sent from AWS Config
6#[non_exhaustive]
7#[derive(Debug, Default, Clone, Eq, PartialEq, Deserialize, Serialize)]
8#[serde(rename_all = "camelCase")]
9pub struct ConfigEvent {
10    /// The ID of the AWS account that owns the rule
11    #[serde(default)]
12    pub account_id: Option<String>,
13    /// The ARN that AWS Config assigned to the rule
14    ///
15    /// nolint:stylecheck
16    #[serde(default)]
17    pub config_rule_arn: Option<String>,
18    /// nolint:stylecheck
19    #[serde(default)]
20    pub config_rule_id: Option<String>,
21    /// The name that you assigned to the rule that caused AWS Config to publish the event
22    #[serde(default)]
23    pub config_rule_name: Option<String>,
24    /// A boolean value that indicates whether the AWS resource to be evaluated has been removed from the rule's scope
25    pub event_left_scope: bool,
26    /// nolint:stylecheck
27    #[serde(default)]
28    pub execution_role_arn: Option<String>,
29    /// If the event is published in response to a resource configuration change, this value contains a JSON configuration item
30    #[serde(default)]
31    pub invoking_event: Option<String>,
32    /// A token that the function must pass to AWS Config with the PutEvaluations call
33    #[serde(default)]
34    pub result_token: Option<String>,
35    /// Key/value pairs that the function processes as part of its evaluation logic
36    #[serde(default)]
37    pub rule_parameters: Option<String>,
38    #[serde(default)]
39    pub version: Option<String>,
40    /// Catchall to catch any additional fields that were present but not explicitly defined by this struct.
41    /// Enabled with Cargo feature `catch-all-fields`.
42    /// If `catch-all-fields` is disabled, any additional fields that are present will be ignored.
43    #[cfg(feature = "catch-all-fields")]
44    #[cfg_attr(docsrs, doc(cfg(feature = "catch-all-fields")))]
45    #[serde(flatten)]
46    pub other: serde_json::Map<String, Value>,
47}
48
49#[cfg(test)]
50mod test {
51    use super::*;
52
53    #[test]
54    #[cfg(feature = "config")]
55    fn example_config_event() {
56        let data = include_bytes!("../../fixtures/example-config-event.json");
57        let parsed: ConfigEvent = serde_json::from_slice(data).unwrap();
58        let output: String = serde_json::to_string(&parsed).unwrap();
59        let reparsed: ConfigEvent = serde_json::from_slice(output.as_bytes()).unwrap();
60        assert_eq!(parsed, reparsed);
61    }
62}