The code examples in this directory show you how to use the AWS Rust SDK with DSQL to create, update, get, and delete single- and multi-Region clusters.
Each file in the examples directory demonstrates a minimum working example for each operation and produces an independent binary that can be executed.
- Running this code might result in charges to your AWS account.
- We recommend that you grant your code least privilege. At most, grant only the minimum permissions required to perform the task. For more information, see Grant least privilege.
- This code is not tested in every AWS Region. For more information, see AWS Regional Services.
- You must have an AWS account, and have your default credentials and AWS Region configured as described in the Globally configuring AWS SDKs and tools
- You must have Rust & Cargo installed.
Set environment variables with your cluster details as required.
# Only relevant for delete/get/update examples.
# e.g. "foo0bar1baz2quux3quuux4"
export CLUSTER_ID="<your id>"
# Relevant for all examples.
# e.g. "us-east-1"
export CLUSTER_REGION="<your region>"# Only relevant for delete/get/update examples.
# e.g. "foo0bar1baz2quux3quuux4"
export CLUSTER_1_ID="<your id 1>"
export CLUSTER_2_ID="<your id 2>"
# Relevant for all examples.
# e.g. "us-east-1"
export CLUSTER_1_REGION="<your region 1>"
export CLUSTER_2_REGION="<your region 2>"
# Only relevant for create examples.
export WITNESS_REGION="<your region 3>"Each example is compiled as a separate binary. You can run them individually:
# Build all examples
cargo build --release
# Run a specific example
./target/release/create_single_region_cluster
./target/release/get_cluster
./target/release/update_cluster
./target/release/delete_single_region_cluster
./target/release/create_multi_region_clusters
./target/release/delete_multi_region_clustersAlternatively, you can use cargo to run a specific example:
cargo run --bin create_single_region_cluster
cargo run --bin get_cluster
# etc.The project includes unit tests that exercise the full lifecycle of both single-region and multi-region clusters:
Since the tests can take up to 5 minutes to run, the --nocapture flag can be used to show more granular progress.
# Run all tests
cargo test -- --nocapture
# Run a specific test
cargo test --test single_region_test -- --nocapture
cargo test --test multi_region_test -- --nocaptureExample execution will take around five minutes as it waits for clusters to complete activation and deletion.
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: MIT-0