File tree Expand file tree Collapse file tree 2 files changed +16
-6
lines changed
examples/examples/dynamodb/src/bin Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change 44#![ allow( clippy:: result_large_err) ]
55
66// snippet-start:[dynamodb.rust.list-tables-local]
7+ use aws_config:: BehaviorVersion ;
78use aws_sdk_dynamodb:: { Client , Error } ;
8- use clap:: Parser ;
9- use dynamodb_code_examples:: { make_config, scenario:: list:: list_tables, Opt } ;
109
1110/// Lists your tables in DynamoDB local.
1211#[ tokio:: main]
1312async fn main ( ) -> Result < ( ) , Error > {
14- let config = make_config ( Opt :: parse ( ) ) . await ?;
13+ let config = aws_config:: defaults ( BehaviorVersion :: latest ( ) )
14+ . test_credentials ( )
15+ . load ( )
16+ . await ;
1517 let dynamodb_local_config = aws_sdk_dynamodb:: config:: Builder :: from ( & config)
18+ // Override the endpoint in the config to use a local dynamodb server.
1619 . endpoint_url (
17- // 8000 is the default dynamodb port
20+ // DynamoDB run locally uses port 8000 by default.
1821 "http://localhost:8000" ,
1922 )
2023 . build ( ) ;
2124
2225 let client = Client :: from_conf ( dynamodb_local_config) ;
23- list_tables ( & client) . await ?;
26+
27+ let resp = client. list_tables ( ) . send ( ) . await ?;
28+
29+ println ! ( "Found {} tables" , resp. table_names( ) . len( ) ) ;
30+ for name in resp. table_names ( ) {
31+ println ! ( " {}" , name) ;
32+ }
33+
2434 Ok ( ( ) )
2535}
2636// snippet-end:[dynamodb.rust.list-tables-local]
Original file line number Diff line number Diff line change 11smithy_rs_revision = ' 4bdd9dab74185c82e92a47efe9bbbe5acd101e13'
2- aws_doc_sdk_examples_revision = ' 8ea9d08a39637e73b2cd2ef03e82a0669d24d6d8 '
2+ aws_doc_sdk_examples_revision = ' 409b9c97b53f96abbe6a0fe52b3a768dcdbd8f5d '
33
44[manual_interventions ]
55crates_to_remove = []
You can’t perform that action at this time.
0 commit comments