These examples demonstrate how to perform several AWS Secrets Manager (Secrets Manager) operations using the developer preview version of the AWS SDK for Rust.
Secrets Manager helps you to securely encrypt, store, and retrieve credentials for your databases and other services.
- [Creates a secret] (src/bin/create-secret.rs) (CreateSecret)
- [Gets the value of a secret] (src/bin/get-secret-value.rs) (GetSecretValue)
- [Lists your secrets] (src/bin/list-secrets.rs) (ListSecrets)
- We recommend that you grant this code least privilege, or at most the minimum permissions required to perform the task. For more information, see Grant Least Privilege in the AWS Identity and Access Management User Guide.
- This code has not been tested in all AWS Regions. Some AWS services are available only in specific Regions.
- Running this code might result in charges to your AWS account.
You must have an AWS account, and have configured your default credentials and AWS Region as described in https://github.com/awslabs/aws-sdk-rust.
This example creates a Secrets Manager secret in the Region.
cargo run --bin create-secret -- -n NAME -s SECRET-VALUE [-r REGION] [-v]
- NAME is the name of the secret.
- SECRET-VALUE is the value of the secret.
- REGION is the Region in which the client is created. If not supplied, uses the value of the AWS_REGION environment variable. If the environment variable is not set, defaults to us-west-2.
- -v displays additional information.
Displays the value of a Secrets Manager secret in the Region.
cargo run --bin get-secret-value -- -n NAME [-r REGION] [-v]
- NAME is the name of the secret.
- REGION is the Region in which the client is created. If not supplied, uses the value of the AWS_REGION environment variable. If the environment variable is not set, defaults to us-west-2.
- -v displays additional information.
This example lists the names of the Secrets Manager secrets in the Region.
cargo run --bin list-secrets -- [-r REGION] [-v]
- REGION is the Region in which the client is created. If not supplied, uses the value of the AWS_REGION environment variable. If the environment variable is not set, defaults to us-west-2.
- -v displays additional information.
- AWS SDK for Rust repo
- AWS SDK for Rust API Reference for Secrets Manager
- AWS SDK for Rust API Reference Guide
To propose a new code example to the AWS documentation team, see CONTRIBUTING.md. The team prefers to create code examples that show broad scenarios rather than individual API calls.
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0