|
| 1 | +# AWS SDK for Rust Developer Guide |
| 2 | + |
| 3 | +This document is a preliminary version of the Developer Guide for the AWS SDK for Rust (the SDK). |
| 4 | + |
| 5 | +This version of the guide is a pared down version of a typical developer guide, with the goal of helping the user quickly and easily download, consume, and use the SDK. |
| 6 | + |
| 7 | +## Getting started |
| 8 | + |
| 9 | +This section briefly describes: |
| 10 | + |
| 11 | +* How to get an Amazon account |
| 12 | +* How to get your AWS access keys |
| 13 | +* How to install the SDK |
| 14 | +* How to add a dependency to an Amazon or AWS package in Cargo.toml |
| 15 | + |
| 16 | +### Getting an Amazon account |
| 17 | + |
| 18 | +Before you can use the AWS SDK for Rust, you must have an Amazon account. See [How do I create and activate a new Amazon Web Services account?](https://aws.amazon.com/premiumsupport/knowledge-center/create-and-activate-aws-account) for details. |
| 19 | + |
| 20 | +### Getting your AWS access keys |
| 21 | + |
| 22 | +Once you have an Amazon account, you need access keys to call any service API using the AWS SDK for Rust. |
| 23 | +For instructions on creating an access key for an existing IAM user, see [Programmatic access](https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys) in the [IAM User Guide](https://docs.aws.amazon.com/IAM/latest/UserGuide/). |
| 24 | + |
| 25 | +### Supported Rust versions |
| 26 | + |
| 27 | +The SDK currently requires a minimum of Rust 1.52.1, and is not guaranteed to build on compiler versions earlier than that. |
| 28 | + |
| 29 | +### Using packages |
| 30 | + |
| 31 | +To access an Amazon or AWS service using the AWS SDK for Rust you must specify the service’s crate in your **Cargo.toml** file. |
| 32 | +For example, to access Amazon Simple Storage Service (Amazon S3) APIs using the v1.0 version of the Rust SDK, you must include the following entry in the `dependencies `section: |
| 33 | + |
| 34 | +``` |
| 35 | +s3 = { git = "https://github.com/awslabs/aws-sdk-rust", tag = "v1.0", package = "aws-sdk-s3" } |
| 36 | +``` |
| 37 | + |
| 38 | +## Using the SDK |
| 39 | + |
| 40 | +This section describes: |
| 41 | + |
| 42 | +* How to specify your credentials |
| 43 | +* The environment variables the SDK acknowledges, such as AWS_REGION |
| 44 | +* How to create a client, including specifying an AWS Region and credentials |
| 45 | + |
| 46 | +### Specifying your credentials and region |
| 47 | + |
| 48 | +Currently the recommended way to specify your credentials is through environment variables. See the following section for information on setting the **AWS_ACCESS_KEY_ID** and **AWS_SECRET_ACCESS_KEY** environment variables. |
| 49 | + |
| 50 | +You can also specify the default AWS Region in which your client is created by using the **AWS_REGION** environment variable. |
| 51 | + |
| 52 | +### Environment variables |
| 53 | + |
| 54 | +The AWS SDK for Rust recognizes the following environment variables: |
| 55 | + |
| 56 | +- **AWS_ACCESS_KEY_ID** is the AWS access key used as part of the credentials to authenticate you. |
| 57 | +- **AWS_SECRET_ACCESS_KEY** is the AWS secret key used as part of the credentials to authenticate you. |
| 58 | +- **AWS_REGION** is the AWS Region to which requests are sent. |
| 59 | + |
| 60 | +To set an environment variable on Linux or MacOS, use the following command, where *VARIABLE* is the name of the environment variable and *VALUE* is the value to which it is set.: |
| 61 | + |
| 62 | +``` |
| 63 | +export VARIABLE=VALUE |
| 64 | +``` |
| 65 | + |
| 66 | +To do the same on Windows: |
| 67 | + |
| 68 | +``` |
| 69 | +set VARIABLE=VALUE |
| 70 | +``` |
| 71 | + |
| 72 | +### Creating a client |
| 73 | + |
| 74 | + To create a client that uses values specified through environment variables, use the Client's `from_env` function. |
| 75 | +The following example creates a client for Amazon S3: |
| 76 | + |
| 77 | +```rust |
| 78 | + let client = s3::Client::from_env(); |
| 79 | +``` |
| 80 | + |
| 81 | +## API reference |
| 82 | + |
| 83 | +You can find the API reference for the AWS SDK for Rust at [https://awslabs.github.io/aws-sdk-rust/](https://awslabs.github.io/aws-sdk-rust/). |
| 84 | + |
| 85 | +## Code examples |
| 86 | + |
| 87 | +The AWS SDK for Rust examples can help you write your own Rust applications that use Amazon Web Services. The examples assume you have already set up and configured the SDK (that is, you have imported all required packages and set your credentials and region). |
| 88 | + |
| 89 | +You can find the source code for these examples and others in the [sdk/examples](sdk/examples) section of this repository. To propose a new code example, create an issue and describe what you want the cod example to do. |
| 90 | +The **sdk/examples** section contains code examples for the following services: |
| 91 | + |
| 92 | +[AWS Batch](sdk/examples/batch) |
| 93 | +[AWS CloudFormation](sdk/examples/cloudformation) |
| 94 | +[Amazon DynamoDB](sdk/examples/dynamodb) |
| 95 | +[Amazon EC2](sdk/examples/ec2) |
| 96 | +[Amazon Kinesis](sdk/examples/kinesis) |
| 97 | +[AWS KMS](sdk/examples/kms) |
| 98 | +[AWS Lambda](sdk/examples/lambda) |
| 99 | +[AWS Elemental MediaLive](sdk/examples/medialive) |
| 100 | +[AWS Elemental MediaPackage](sdk/examples/mediapackage) |
| 101 | +[Amazon Polly](sdk/examples/polly) |
| 102 | +[Amazon QLDB](sdk/examples/qldb) |
| 103 | +[Amazon RDS](sdk/examples/rds) |
| 104 | +[Amazon RDS Data](sdk/examples/rdsdata) |
| 105 | +[Amazon Route 53](sdk/examples/route53) |
| 106 | +[Amazon S3](sdk/examples/s3) |
| 107 | +[Amazon SageMaker](sdk/examples/sagemaker) |
| 108 | +[AWS Secrets Manager](sdk/examples/secretsmanager) |
| 109 | +[Amazon SES](sdk/examples/ses) |
| 110 | +[Amazon SNS](sdk/examples/sns) |
| 111 | +[Amazon SQS](sdk/examples/sqs) |
| 112 | +[AWS Systems Manager](sdk/examples/ssm) |
| 113 | +[AWS STS](sdk/examples/sts) |
0 commit comments