Skip to content
Merged
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
17 changes: 9 additions & 8 deletions examples/http-dynamodb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ edition = "2021"
# and it will keep the alphabetic ordering for you.

[dependencies]
simple-error = "0.2.3"
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
simple-error = "0.3.0"
serde_json = "1.0.107"
serde = { version = "1.0.189", features = ["derive"] }
serde_dynamo = {version = "^4.2.7", features = ["aws-sdk-dynamodb+0_33"]}
lambda_http = { path = "../../lambda-http" }
lambda_runtime = { path = "../../lambda-runtime" }
aws-sdk-dynamodb = "0.21.0"
aws-config = "0.51.0"
tokio = { version = "1", features = ["macros"] }
tracing = { version = "0.1", features = ["log"] }
tracing-subscriber = { version = "0.3", default-features = false, features = ["fmt"] }
aws-sdk-dynamodb = "0.33.0"
aws-config = "0.56.1"
tokio = { version = "1.33.0", features = ["macros"] }
tracing = { version = "0.1.40", features = ["log"] }
tracing-subscriber = { version = "0.3.17", default-features = false, features = ["fmt"] }


19 changes: 10 additions & 9 deletions examples/http-dynamodb/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use aws_sdk_dynamodb::model::AttributeValue;
use aws_sdk_dynamodb::{Client, Error as OtherError};
use aws_sdk_dynamodb::{Client};
use lambda_http::{run, service_fn, Body, Error, Request, Response};
use serde::{Deserialize, Serialize};
use serde_dynamo::to_attribute_value;
use tracing::info;

#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Item {
pub p_type: String,
pub age: String,
Expand Down Expand Up @@ -76,12 +77,12 @@ async fn main() -> Result<(), Error> {

// Add an item to a table.
// snippet-start:[dynamodb.rust.add-item]
pub async fn add_item(client: &Client, item: Item, table: &str) -> Result<(), OtherError> {
let user_av = AttributeValue::S(item.username);
let type_av = AttributeValue::S(item.p_type);
let age_av = AttributeValue::S(item.age);
let first_av = AttributeValue::S(item.first);
let last_av = AttributeValue::S(item.last);
pub async fn add_item(client: &Client, item: Item, table: &str) -> Result<(), Error> {
let user_av = to_attribute_value(item.username)?;
let type_av = to_attribute_value(item.p_type)?;
let age_av = to_attribute_value(item.age)?;
let first_av = to_attribute_value(item.first)?;
let last_av = to_attribute_value(item.last)?;

let request = client
.put_item()
Expand Down