AWS Developer Tools Blog

Announcing general availability of the AWS SDK for Rust

We’re excited to announce that the AWS SDK for Rust is now generally available and supported for production use.

The AWS SDK for Rust provides an idiomatic, type-safe API, along with the benefits of the Rust language such as performance, reliability, and productivity. The SDK supports modern Rust language features like async/await, non-blocking IO, and builders. It provides access to 300+ AWS Services, each with their own crate. The SDK works out of the box using sensible defaults but it’s also extensible, allowing users to customize it to their unique use case. The SDK is modular, allowing customers to compile crates only for the services they use. It’s also engineered to be fast. With the Rust SDK, users can quickly transfer data to and from Amazon Simple Storage Service (Amazon S3), Amazon Elastic Compute Cloud (Amazon EC2), and Amazon DynamoDB.

Getting Started with AWS SDK for Rust

You can access the SDK through crates.io. The following is an example of how to use the AWS SDK for Rust with DynamoDB to perform a common operation of listing your tables. This example assumes you already have Rust and Cargo installed (If you don’t, you can follow these instructions to install Rust and Cargo.)

Create a new Rust project using cargo:

cd <your-project-directory>
cargo new <name-of-your-new-rust-project>

If this is the first time you are using an AWS SDK, you will need to set up your AWS credentials. We recommend authenticating with short-term credentials.

Adding SDK crates to your dependencies

Now that you’ve created your new Rust project, we’ll add some SDK crates and an async runtime. Add the following lines under [dependencies] in your new project’s Cargo.toml file:

[dependencies]
aws-config = { version = "1", features = ["behavior-version-latest"] }
aws-sdk-dynamodb = "1"
tokio = { version = "1", features = ["full"] }

Here’s what each of those crates does:

  • aws-config: While not strictly required, this crate makes it easy to create the configuration needed by the DynamoDB client we’ll be creating. It will handle the sourcing of AWS credentials as well as providing useful defaults.
  • aws-sdk-dynamodb: This crate provides the client for the service we want to interact with.
  • tokio: The AWS SDK for Rust has an async API, so an async runtime is required to run our requests. We recommend the Tokio runtime. It’s well-supported by our SDK.

Listing your DynamoDB tables with the Rust SDK

We’re ready to write our main function now:

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let sdk_config = aws_config::load_from_env().await;
    let client = aws_sdk_dynamodb::Client::new(&sdk_config);
    let res = client
        .list_tables()
        .limit(10)
        .send()
        .await?;
    println!("Current DynamoDB tables: {:?}", res.table_names());
    Ok(())
}

You can now run the example program with cargo:

cargo run

The result is a list of your DynamoDB tables, or a helpful error message explaining why your request couldn’t be completed.

You can access many more examples in the SDK repository.

Contributing to the SDK’s development

We would like to thank everyone that submitted issues and PRs during developer preview of the AWS SDK for Rust.

We continue to accept contributions. See our contributing guidelines to learn more.

Following are a few ways you can help:

  • Vote for the new features most important to you — We prioritize feature work based on the needs of our customers so add your comments and “+1”s to GitHub Issues that are important to you.
  • Report defects — We are committed to continued production support without breaking changes. However, please submit a GitHub Issue if you run into unexpected behavior or want to report an issue. Kindly include an SSCCE to help us reproduce the issue.
  • Review the docs — The AWS SDK for Rust comes with support for documentation and code examples. Please create a GitHub issue for any feedback for the supported documentation or code examples.
  • Join in on the discussion — When customers have a question but don’t feel like it warrants opening a new issue, they start a new discussion. If a customer’s issue sounds familiar to you, feel free to help them out. I’m sure they’ll appreciate it.

Our SDK’s Public Roadmap

The AWS SDK for Rust supports 300+ services and we will continue to add support for new services and features in the future. If you’d like to see what we’re working on, you can view our public roadmap. Please add a “+1” to the features that are important to you. Your votes help us to prioritize our roadmap.

Give it a try!

If you’re ready to start using the AWS SDK for Rust in your own project, the “Getting Started” guide is a great place to learn more. Check it out and let us know what do you think!

About the author:

Zelda Hessler

Zelda Hessler

Zelda has worked on the AWS SDK for Rust since 2021. She is a former web developer and a fan of the Rust programming language since 2015. Check out her art, writing, and music on her personal website: https://zeldas.page