The code examples in this directory show you how to use the AWS .NET SDK with DSQL to create, update, get, and delete single- and multi-Region clusters.
Each project in the examples directory demonstrates a minimum working example for each operation and produces an independent executable that can be run.
- 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 .NET 9.0 SDK 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 a standalone project that can be run independently:
# Build all examples
dotnet build
# Run a specific example
dotnet run --framework net9.0 --project examples/CreateSingleRegionCluster
dotnet run --framework net9.0 --project examples/CreateMultiRegionClusters
dotnet run --framework net9.0 --project examples/GetCluster
dotnet run --framework net9.0 --project examples/UpdateCluster
dotnet run --framework net9.0 --project examples/DeleteSingleRegionCluster
dotnet run --framework net9.0 --project examples/DeleteMultiRegionClustersThe project includes unit tests that exercise the full lifecycle of both single-region and multi-region clusters:
# Run all tests
dotnet test
# Run a specific test
dotnet test --filter "DisplayName~TestSingleRegionClusterLifecycle"
dotnet test --filter "DisplayName~TestMultiRegionClusterLifecycle"These examples do not wait for cluster operations to complete. Clusters may still be changing state after an example has finished executing.
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: MIT-0