Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-events.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
strategy:
matrix:
toolchain:
- "1.84.0" # Current MSRV
- "1.85.0" # Current MSRV
- stable
env:
RUST_BACKTRACE: 1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
strategy:
matrix:
toolchain:
- "1.84.0" # Current MSRV
- "1.85.0" # Current MSRV
- stable
env:
RUST_BACKTRACE: 1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
strategy:
matrix:
toolchain:
- "1.84.0" # Current MSRV
- "1.85.0" # Current MSRV
- stable
env:
RUST_BACKTRACE: 1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
strategy:
matrix:
toolchain:
- "1.84.0" # Current MSRV
- "1.85.0" # Current MSRV
- stable
env:
RUST_BACKTRACE: 1
Expand Down
6 changes: 1 addition & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ exclude = ["examples","lambda-events/lambda-events-examples"]
[workspace.dependencies]
base64 = "0.22"
bytes = "1"
chrono = { version = "0.4.35", default-features = false, features = [
"clock",
"serde",
"std",
] }
futures = "0.3"
futures-channel = "0.3"
futures-util = "0.3"
Expand All @@ -28,6 +23,7 @@ http-body-util = "0.1"
http-serde = "2.0"
hyper = "1.0"
hyper-util = "0.1.1"
jiff = { version = "1", default-features = false, features = ["serde", "std"] }
pin-project-lite = "0.2"
tower = "0.5"
tower-layer = "0.3"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ async fn handler(

## Supported Rust Versions (MSRV)

The AWS Lambda Rust Runtime requires a minimum of Rust 1.84.0, and is not guaranteed to build on compiler versions earlier than that.
The AWS Lambda Rust Runtime requires a minimum of Rust 1.85.0, and is not guaranteed to build on compiler versions earlier than that.

## Security

Expand Down
2 changes: 1 addition & 1 deletion examples/basic-s3-thumbnail/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ async-trait = "0.1.88"

[dev-dependencies]
mockall = "0.13.1"
chrono = "0.4"
jiff = "1"
3 changes: 1 addition & 2 deletions examples/basic-s3-thumbnail/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ mod tests {

use super::*;
use async_trait::async_trait;
//use aws_lambda_events::chrono::DateTime;
use aws_lambda_events::s3::{S3Bucket, S3Entity, S3Object, S3RequestParameters, S3UserIdentity};
use aws_sdk_s3::operation::get_object::GetObjectError;
use lambda_runtime::{Context, LambdaEvent};
Expand Down Expand Up @@ -218,7 +217,7 @@ mod tests {
s3_event_record.event_version = Some(String::default());
s3_event_record.event_source = Some(String::default());
s3_event_record.aws_region = Some(String::default());
s3_event_record.event_time = chrono::DateTime::default();
s3_event_record.event_time = jiff::Timestamp::default();
s3_event_record.event_name = Some(event_name.to_string());
s3_event_record.principal_id = {
let mut s3_user_identity = S3UserIdentity::default();
Expand Down
36 changes: 18 additions & 18 deletions lambda-events/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "aws_lambda_events"
version = "1.2.1"
rust-version = "1.84.0"
rust-version = "1.85.0"
description = "AWS Lambda event definitions"
authors = [
"Christian Legnitto <christian@legnitto.com>",
Expand All @@ -19,7 +19,7 @@ edition = "2021"
[dependencies]
base64 = { workspace = true }
bytes = { workspace = true, features = ["serde"], optional = true }
chrono = { workspace = true, optional = true }
jiff = { workspace = true, optional = true }
bon = { version = "3", optional = true }
flate2 = { version = "1.0.24", optional = true }
http = { workspace = true, optional = true }
Expand Down Expand Up @@ -87,47 +87,47 @@ activemq = []
alb = ["bytes", "http", "http-body", "http-serde", "query_map"]
apigw = ["bytes", "http", "http-body", "http-serde", "iam", "query_map"]
appsync = []
autoscaling = ["chrono"]
autoscaling = ["jiff"]
bedrock_agent_runtime = []
chime_bot = ["chrono"]
chime_bot = ["jiff"]
clientvpn = []
cloudformation = []
cloudwatch_alarms = ["chrono"]
cloudwatch_events = ["chrono"]
cloudwatch_alarms = ["jiff"]
cloudwatch_events = ["jiff"]
cloudwatch_logs = ["flate2"]
code_commit = ["chrono"]
codebuild = ["chrono"]
codedeploy = ["chrono"]
code_commit = ["jiff"]
codebuild = ["jiff"]
codedeploy = ["jiff"]
codepipeline = []
codepipeline_cloudwatch = ["chrono"]
codepipeline_cloudwatch = ["jiff"]
codepipeline_job = []
cognito = []
config = []
connect = []
controltower = []
dynamodb = ["chrono", "serde_dynamo", "streams"]
dynamodb = ["jiff", "serde_dynamo", "streams"]
ecr_scan = []
firehose = ["chrono"]
firehose = ["jiff"]
iam = []
iot = ["bytes", "http", "http-body", "http-serde", "iam"]
iot_1_click = []
iot_button = []
iot_deprecated = ["iot"]
kafka = ["chrono"]
kinesis = ["chrono"]
kafka = ["jiff"]
kinesis = ["jiff"]
kinesis_analytics = ["kinesis"]
lambda_function_urls = ["bytes", "http", "http-body", "http-serde"]
lex = []
rabbitmq = []
s3 = ["bytes", "chrono", "http", "http-body", "http-serde"]
s3 = ["bytes", "jiff", "http", "http-body", "http-serde"]
s3_batch_job = ["s3"]
secretsmanager = []
ses = ["chrono"]
sns = ["chrono", "serde_with"]
ses = ["jiff"]
sns = ["jiff", "serde_with"]
sqs = ["serde_with"]
streams = []
documentdb = []
eventbridge = ["chrono", "serde_with"]
eventbridge = ["jiff", "serde_with"]
vpc_lattice = ["bytes", "http", "http-body", "http-serde", "iam", "query_map"]

catch-all-fields = []
Expand Down
2 changes: 1 addition & 1 deletion lambda-events/lambda-events-examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ aws_lambda_events = { path = "..", features = ["builders"] }
lambda_runtime = { path = "../../lambda-runtime" }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
chrono = { version = "0.4", default-features = false, features = ["clock"] }
jiff = { version = "1", default-features = false, features = ["std"] }
serde_dynamo = "4"

[[example]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::collections::HashMap;
fn main() {
// S3 Event - Object storage notifications with nested structures
let s3_record = S3EventRecord::builder()
.event_time(chrono::Utc::now())
.event_time(jiff::Timestamp::now())
.principal_id(S3UserIdentity::builder().build())
.request_parameters(S3RequestParameters::builder().build())
.response_elements(HashMap::new())
Expand Down Expand Up @@ -42,7 +42,7 @@ fn main() {
let dynamodb_record = DynamoDbEventRecord::builder()
.aws_region("us-east-1".to_string())
.change(StreamRecord::builder()
.approximate_creation_date_time(chrono::Utc::now())
.approximate_creation_date_time(jiff::Timestamp::now())
.keys(keys.into())
.new_image(HashMap::new().into())
.old_image(HashMap::new().into())
Expand All @@ -63,7 +63,7 @@ fn main() {
.sns_message_type("Notification".to_string())
.message_id("msg-123".to_string())
.topic_arn("arn:aws:sns:us-east-1:123456789012:topic".to_string())
.timestamp(chrono::Utc::now())
.timestamp(jiff::Timestamp::now())
.signature_version("1".to_string())
.signature("sig".to_string())
.signing_cert_url("https://cert.url".to_string())
Expand Down
34 changes: 17 additions & 17 deletions lambda-events/src/custom_serde/codebuild_time.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use chrono::{DateTime, NaiveDateTime, Utc};
use jiff::{civil::DateTime, tz::TimeZone, Timestamp};
use serde::{
de::{Deserializer, Error as DeError, Visitor},
ser::Serializer,
Expand All @@ -11,39 +11,43 @@ const CODEBUILD_TIME_FORMAT: &str = "%b %e, %Y %l:%M:%S %p";

struct TimeVisitor;
impl Visitor<'_> for TimeVisitor {
type Value = DateTime<Utc>;
type Value = Timestamp;

fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(formatter, "valid codebuild time: {CODEBUILD_TIME_FORMAT}")
}

fn visit_str<E: DeError>(self, val: &str) -> Result<Self::Value, E> {
NaiveDateTime::parse_from_str(val, CODEBUILD_TIME_FORMAT)
.map(|naive| naive.and_utc())
.map_err(|e| DeError::custom(format!("Parse error {e} for {val}")))
parse(val).map_err(|e| DeError::custom(format!("Parse error {e} for {val}")))
}
}

fn parse(val: &str) -> Result<Timestamp, jiff::Error> {
DateTime::strptime(CODEBUILD_TIME_FORMAT, val)?
.to_zoned_datetime(TimeZone::UTC)
.map(|zdt| zdt.timestamp())
}

pub(crate) mod str_time {
use super::*;

pub(crate) fn deserialize<'de, D>(d: D) -> Result<DateTime<Utc>, D::Error>
pub(crate) fn deserialize<'de, D>(d: D) -> Result<Timestamp, D::Error>
where
D: Deserializer<'de>,
{
d.deserialize_str(TimeVisitor)
}

pub fn serialize<S: Serializer>(date: &DateTime<Utc>, ser: S) -> Result<S::Ok, S::Error> {
let s = format!("{}", date.format(CODEBUILD_TIME_FORMAT));
pub fn serialize<S: Serializer>(date: &Timestamp, ser: S) -> Result<S::Ok, S::Error> {
let s = date.strftime(CODEBUILD_TIME_FORMAT).to_string();
ser.serialize_str(&s)
}
}

pub(crate) mod optional_time {
use super::*;

pub(crate) fn deserialize<'de, D>(deserializer: D) -> Result<Option<DateTime<Utc>>, D::Error>
pub(crate) fn deserialize<'de, D>(deserializer: D) -> Result<Option<Timestamp>, D::Error>
where
D: Deserializer<'de>,
{
Expand All @@ -56,7 +60,7 @@ pub(crate) mod optional_time {
Ok(None)
}

pub fn serialize<S: Serializer>(date: &Option<DateTime<Utc>>, ser: S) -> Result<S::Ok, S::Error> {
pub fn serialize<S: Serializer>(date: &Option<Timestamp>, ser: S) -> Result<S::Ok, S::Error> {
if let Some(date) = date {
return str_time::serialize(date, ser);
}
Expand All @@ -69,7 +73,7 @@ pub(crate) mod optional_time {
mod tests {
use super::*;

type TestTime = DateTime<Utc>;
type TestTime = Timestamp;

#[test]
fn test_deserialize_codebuild_time() {
Expand All @@ -82,9 +86,7 @@ mod tests {
"date": "Sep 1, 2017 4:12:29 PM"
});

let expected = NaiveDateTime::parse_from_str("Sep 1, 2017 4:12:29 PM", CODEBUILD_TIME_FORMAT)
.unwrap()
.and_utc();
let expected: Timestamp = "2017-09-01T16:12:29Z".parse().unwrap();
let decoded: Test = serde_json::from_value(data).unwrap();
assert_eq!(expected, decoded.date);
}
Expand All @@ -100,9 +102,7 @@ mod tests {
"date": "Sep 1, 2017 4:12:29 PM"
});

let expected = NaiveDateTime::parse_from_str("Sep 1, 2017 4:12:29 PM", CODEBUILD_TIME_FORMAT)
.unwrap()
.and_utc();
let expected: Timestamp = "2017-09-01T16:12:29Z".parse().unwrap();
let decoded: Test = serde_json::from_value(data).unwrap();
assert_eq!(Some(expected), decoded.date);
}
Expand Down
Loading