aws-sdk-rust
aws-sdk-rust copied to clipboard
Cannot Query tables with dynamodb sdk depending on how the table is named.
trafficstars
Describe the bug
DynamoDB tables cannot be queried if table has number at the beginning of the name or a hyphen/period anywhere in the name.
Entries with X cannot be queried. Sdk will return service error.
Expected Behavior
All tables with valid names should be able to be queried.
Current Behavior
Querying tables where the name starts with a number or contains a hyphen/period causes the query to fail and return a service error.
Reproduction Steps
First create a table in dynamoDB using any method.
Run this code in a lambda function.
use lambda_http::{run, service_fn, tracing, Body, Error, Request, RequestExt, Response};
use aws_config::{self, BehaviorVersion, Region};
use aws_sdk_dynamodb::client as DDBClient;
const EXAMPLE_TABLE: &str = "018e8b50-7a46-7d26-9fc0-d0da4e8d9dfc-EXAMPLE";
async fn function_handler(event: Request) -> Result<Response<Body>, Error> {
let config = aws_config::defaults(BehaviorVersion::latest()).region(Region::new("us-east-2")).load().await;
let client = DDBClient::new(&config);
let sql = format!("SELECT * FROM {}", USERS_TABLE);
match client.execute_statement().statement(sql).send().await {
Ok(cool) => println!("Thats cool {:?}", cool),
Err(e) => println!("{e}"),
}
let message = format!("Hello World, this is an AWS Lambda HTTP request");
let resp = Response::builder()
.status(200)
.header("content-type", "text/html")
.body(message.into())
.map_err(Box::new)?;
Ok(resp)
}
#[tokio::main]
async fn main() -> Result<(), Error> {
tracing::init_default_subscriber();
run(service_fn(function_handler)).await
}
Possible Solution
No response
Additional Information/Context
Bug was found while using the cargo lambda watch command. In a lambda function.
Version
[dependencies]
aws-config = "1.1.9"
aws-sdk-dynamodb = "1.20.0"
lambda_http = "0.11.0"
tokio = { version = "1", features = ["macros"] }
Environment details (OS name and version, etc.)
MacOS Ventura Version 13.6.4
Logs
No response