Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions,
see Getting Started with Amazon Web Services in China
(PDF).
Connect to a local DynamoDB instance using an Amazon SDK
The following code example shows how to override an endpoint URL to connect to a local development deployment of DynamoDB and an Amazon SDK.
For more information, see DynamoDB Local.
- Rust
-
- SDK for Rust
-
/// Lists your tables from a local DynamoDB instance by setting the SDK Config's
/// endpoint_url and test_credentials.
#[tokio::main]
async fn main() {
tracing_subscriber::fmt::init();
let config = aws_config::defaults(aws_config::BehaviorVersion::latest())
.test_credentials()
// DynamoDB run locally uses port 8000 by default.
.endpoint_url("http://localhost:8000")
.load()
.await;
let dynamodb_local_config = aws_sdk_dynamodb::config::Builder::from(&config).build();
let client = aws_sdk_dynamodb::Client::from_conf(dynamodb_local_config);
let list_resp = client.list_tables().send().await;
match list_resp {
Ok(resp) => {
println!("Found {} tables", resp.table_names().len());
for name in resp.table_names() {
println!(" {}", name);
}
}
Err(err) => eprintln!("Failed to list local dynamodb tables: {err:?}"),
}
}
For a complete list of Amazon SDK developer guides and code examples, see
Using DynamoDB with an Amazon SDK.
This topic also includes information about getting started and details about previous SDK versions.