diff --git a/Cargo.toml b/Cargo.toml index 8773eb9..389156a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,12 +6,12 @@ edition = "2021" [dependencies] async-trait = "0.1" -aws-config = "0.4" -aws-sdk-dynamodb = "0.4" -aws-sdk-eventbridge = "0.4" -aws-smithy-client = { version = "0.34", features = ["test-util"] } -aws-smithy-http = "0.34" -aws-types = "0.4" +aws-config = "0.6" +aws-sdk-dynamodb = "0.6" +aws-sdk-eventbridge = "0.6" +aws-smithy-client = { version = "0.36", features = ["test-util"] } +aws-smithy-http = "0.36" +aws-types = "0.6" futures = { version = "0.3", features = ["std"] } lambda_runtime = { version = "0.4", optional = true } lambda_http = { version = "0.4", optional = true } diff --git a/src/event_bus/eventbridge/mod.rs b/src/event_bus/eventbridge/mod.rs index e7ab068..3cb314e 100644 --- a/src/event_bus/eventbridge/mod.rs +++ b/src/event_bus/eventbridge/mod.rs @@ -96,7 +96,13 @@ mod tests { async fn get_mock_config() -> Config { let cfg = aws_config::from_env() .region(Region::new("eu-west-1")) - .credentials_provider(Credentials::from_keys("accesskey", "privatekey", None)) + .credentials_provider(Credentials::new( + "accesskey", + "privatekey", + None, + None, + "dummy", + )) .load() .await; diff --git a/src/store/dynamodb/mod.rs b/src/store/dynamodb/mod.rs index 0f2acc3..74454c7 100644 --- a/src/store/dynamodb/mod.rs +++ b/src/store/dynamodb/mod.rs @@ -17,27 +17,21 @@ use ext::AttributeValuesExt; /// We have to pass a generic type parameter `C` for the underlying client, /// restricted to something that implements the SmithyConnector trait so we can /// use it with both the actual AWS SDK client and a mock implementation. -pub struct DynamoDBStore { - client: Client, +pub struct DynamoDBStore { + client: Client, table_name: String, } -impl DynamoDBStore -where - C: aws_smithy_client::bounds::SmithyConnector, -{ - pub fn new(client: Client, table_name: String) -> DynamoDBStore { +impl DynamoDBStore { + pub fn new(client: Client, table_name: String) -> DynamoDBStore { DynamoDBStore { client, table_name } } } -impl Store for DynamoDBStore where C: aws_smithy_client::bounds::SmithyConnector {} +impl Store for DynamoDBStore {} #[async_trait] -impl StoreGetAll for DynamoDBStore -where - C: aws_smithy_client::bounds::SmithyConnector, -{ +impl StoreGetAll for DynamoDBStore { /// Get all items #[instrument(skip(self))] async fn all(&self, next: Option<&str>) -> Result { @@ -65,10 +59,7 @@ where } #[async_trait] -impl StoreGet for DynamoDBStore -where - C: aws_smithy_client::bounds::SmithyConnector, -{ +impl StoreGet for DynamoDBStore { /// Get item #[instrument(skip(self))] async fn get(&self, id: &str) -> Result, Error> { @@ -89,10 +80,7 @@ where } #[async_trait] -impl StorePut for DynamoDBStore -where - C: aws_smithy_client::bounds::SmithyConnector, -{ +impl StorePut for DynamoDBStore { /// Create or update an item #[instrument(skip(self))] async fn put(&self, product: &Product) -> Result<(), Error> { @@ -109,10 +97,7 @@ where } #[async_trait] -impl StoreDelete for DynamoDBStore -where - C: aws_smithy_client::bounds::SmithyConnector, -{ +impl StoreDelete for DynamoDBStore { /// Delete item #[instrument(skip(self))] async fn delete(&self, id: &str) -> Result<(), Error> { @@ -168,14 +153,20 @@ mod tests { use super::*; use crate::Error; use aws_sdk_dynamodb::{Client, Config, Credentials, Region}; - use aws_smithy_client::test_connection::TestConnection; + use aws_smithy_client::{erase::DynConnector, test_connection::TestConnection}; use aws_smithy_http::body::SdkBody; /// Config for mocking DynamoDB async fn get_mock_config() -> Config { let cfg = aws_config::from_env() .region(Region::new("eu-west-1")) - .credentials_provider(Credentials::from_keys("accesskey", "privatekey", None)) + .credentials_provider(Credentials::new( + "accesskey", + "privatekey", + None, + None, + "dummy", + )) .load() .await; @@ -203,7 +194,8 @@ mod tests { .body(SdkBody::from(r#"{"Items": []}"#)) .unwrap(), )]); - let client = Client::from_conf_conn(get_mock_config().await, conn.clone()); + let client = + Client::from_conf_conn(get_mock_config().await, DynConnector::new(conn.clone())); let store = DynamoDBStore::new(client, "test".to_string()); // WHEN getting all items @@ -229,7 +221,8 @@ mod tests { .body(SdkBody::from(r#"{"Items": [{"id": {"S": "1"}, "name": {"S": "test1"}, "price": {"N": "1.0"}}]}"#)) .unwrap(), )]); - let client = Client::from_conf_conn(get_mock_config().await, conn.clone()); + let client = + Client::from_conf_conn(get_mock_config().await, DynConnector::new(conn.clone())); let store = DynamoDBStore::new(client, "test".to_string()); // WHEN getting all items @@ -264,7 +257,8 @@ mod tests { )) .unwrap(), )]); - let client = Client::from_conf_conn(get_mock_config().await, conn.clone()); + let client = + Client::from_conf_conn(get_mock_config().await, DynConnector::new(conn.clone())); let store = DynamoDBStore::new(client, "test".to_string()); // WHEN getting all items @@ -293,7 +287,8 @@ mod tests { .body(SdkBody::from("{}")) .unwrap(), )]); - let client = Client::from_conf_conn(get_mock_config().await, conn.clone()); + let client = + Client::from_conf_conn(get_mock_config().await, DynConnector::new(conn.clone())); let store = DynamoDBStore::new(client, "test".to_string()); // WHEN deleting an item @@ -318,7 +313,8 @@ mod tests { .body(SdkBody::from(r#"{"Item": {"id": {"S": "1"}, "name": {"S": "test1"}, "price": {"N": "1.0"}}}"#)) .unwrap(), )]); - let client = Client::from_conf_conn(get_mock_config().await, conn.clone()); + let client = + Client::from_conf_conn(get_mock_config().await, DynConnector::new(conn.clone())); let store = DynamoDBStore::new(client, "test".to_string()); // WHEN getting an item @@ -351,7 +347,8 @@ mod tests { .body(SdkBody::from(r#"{"Attributes": {"id": {"S": "1"}, "name": {"S": "test1"}, "price": {"N": "1.5"}}}"#)) .unwrap(), )]); - let client = Client::from_conf_conn(get_mock_config().await, conn.clone()); + let client = + Client::from_conf_conn(get_mock_config().await, DynConnector::new(conn.clone())); let store = DynamoDBStore::new(client, "test".to_string()); let product = Product { id: "1".to_string(),