1 1 | <!--
|
2 2 | IMPORTANT:
|
3 3 | This README file is auto-generated by the build system in smithy-lang/smithy-rs.
|
4 4 | To update it, edit the `aws/SDK_README.md.hb` Handlebars template in that repository.
|
5 5 | -->
|
6 6 |
|
7 7 | # The AWS SDK for Rust [![Docs](https://img.shields.io/badge/docs-blue)](https://awslabs.github.io/aws-sdk-rust/) ![MSRV](https://img.shields.io/badge/msrv-1.76.0-red) [![Usage Guide](https://img.shields.io/badge/Developer_Guide-blue)](https://docs.aws.amazon.com/sdk-for-rust/latest/dg/welcome.html)
|
8 8 |
|
9 9 | This repo contains the AWS SDK for Rust and its [public roadmap](https://github.com/orgs/awslabs/projects/50/views/1).
|
10 10 |
|
11 11 | The SDK is code generated from [Smithy models](https://smithy.io/2.0/index.html) that represent each AWS service.
|
12 12 | The code used to generate the SDK can be found in [smithy-rs](https://github.com/smithy-lang/smithy-rs).
|
13 13 |
|
14 14 | ## Getting Started with the SDK
|
15 15 |
|
16 16 | > Examples are available for many services and operations, check out the [examples folder](./examples).
|
17 17 |
|
18 18 | > For a step-by-step guide including several advanced use cases, check out the [Developer Guide](https://docs.aws.amazon.com/sdk-for-rust/latest/dg/welcome.html).
|
19 19 |
|
20 20 | The SDK provides one crate per AWS service. You must add [Tokio](https://crates.io/crates/tokio) as a dependency within your Rust project to execute asynchronous code.
|
21 21 |
|
22 22 | 1. Create a new Rust project: `cargo new sdk-example`
|
23 23 | 2. Add dependencies to DynamoDB and Tokio to your **Cargo.toml** file:
|
24 24 |
|
25 25 | ```toml
|
26 26 | [dependencies]
|
27 - | aws-config = { version= "1.5.1", features = ["behavior-version-latest"] }
|
27 + | aws-config = { version= "1.5.2", features = ["behavior-version-latest"] }
|
28 28 | aws-sdk-dynamodb = "0.0.0-local"
|
29 29 | tokio = { version = "1", features = ["full"] }
|
30 30 | ```
|
31 31 |
|
32 32 | 3. Provide your AWS credentials with the default credential provider chain, which currently looks in:
|
33 33 | - Environment variables: `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_REGION`
|
34 34 | - The default credentials files located in `~/.aws/config` and `~/.aws/credentials` (location can vary per platform)
|
35 35 | - Web Identity Token credentials from the environment or container (including EKS)
|
36 36 | - ECS Container Credentials (IAM roles for tasks)
|
37 37 | - EC2 Instance Metadata Service (IAM Roles attached to instance)
|
38 38 |
|
39 39 | 4. Make a request using DynamoDB
|
40 40 |
|
41 41 | ```rust
|
42 42 | use aws_sdk_dynamodb::{Client, Error};
|
43 43 |
|
44 44 | #[tokio::main]
|
45 45 | async fn main() -> Result<(), Error> {
|
46 46 | let shared_config = aws_config::load_from_env().await;
|
47 47 | let client = Client::new(&shared_config);
|
48 48 | let req = client.list_tables().limit(10);
|
49 49 | let resp = req.send().await?;
|
50 50 | println!("Current DynamoDB tables: {:?}", resp.table_names);
|
51 51 | Ok(())
|
52 52 | }
|
53 53 | ```
|
54 54 |
|
55 55 | ### Prerequisites
|
56 56 |
|
57 57 | In order to use the SDK, you must already have Rust and Cargo installed. If you don't, [these instructions](https://doc.rust-lang.org/book/ch01-01-installation.html) describe how to install Rust and Cargo.
|