AWS Security ChangesHomeSearch

AWS aurora-dsql documentation change

Service: aurora-dsql · 2025-05-19 · Documentation low

File: aurora-dsql/latest/userguide/getting-started-get-cluster.md

Summary

Updated code examples across multiple languages to use placeholder cluster IDs, improve error handling, and standardize client initialization patterns

Security assessment

Changes focus on code quality improvements and example standardization. No security vulnerabilities are mentioned or addressed. Updates include placeholder values (<your cluster id>) instead of hardcoded examples and enhanced error messages, but these are general documentation improvements without security implications.

Diff

diff --git a/aurora-dsql/latest/userguide/getting-started-get-cluster.md b/aurora-dsql/latest/userguide/getting-started-get-cluster.md
index 0ee6c606a..ba74ec08c 100644
--- a//aurora-dsql/latest/userguide/getting-started-get-cluster.md
+++ b//aurora-dsql/latest/userguide/getting-started-get-cluster.md
@@ -7 +7 @@ Amazon Aurora DSQL is provided as a Preview service. To learn more, see [Betas a
-# Get a cluster in Aurora DSQL with the AWS SDKs
+# Get a cluster 
@@ -17,0 +18,2 @@ To get information about a single or a multi-Region cluster, use the following e
+    from datetime import datetime
+    import json
@@ -19 +21,2 @@ To get information about a single or a multi-Region cluster, use the following e
-    def get_cluster(cluster_id, client):
+    
+    def get_cluster(region, identifier):
@@ -21 +24,2 @@ To get information about a single or a multi-Region cluster, use the following e
-            return client.get_cluster(identifier=cluster_id)
+            client = boto3.client("dsql", region_name=region)
+            return client.get_cluster(identifier=identifier)
@@ -23 +27 @@ To get information about a single or a multi-Region cluster, use the following e
-            print("Unable to get cluster")
+            print(f"Unable to get cluster {identifier} in region {region}")
@@ -28,4 +33,4 @@ To get information about a single or a multi-Region cluster, use the following e
-        client = boto3.client("dsql", region_name=region)
-        cluster_id = "foo0bar1baz2quux3quuux4"
-        response = get_cluster(cluster_id, client)
-        print("Cluster Status: " + response['status'])
+        cluster_id = "<your cluster id>"
+        response = get_cluster(region, cluster_id)
+    
+        print(json.dumps(response, indent=2, default=lambda obj: obj.isoformat() if isinstance(obj, datetime) else None))
@@ -44,0 +50 @@ Use the following example to get information about a single or a multi-Region cl
+    #include <aws/core/utils/Outcome.h>
@@ -47 +52,0 @@ Use the following example to get information about a single or a multi-Region cl
-    #include <aws/dsql/model/ClusterStatus.h>
@@ -54,11 +59,18 @@ Use the following example to get information about a single or a multi-Region cl
-    ClusterStatus getCluster(const String& clusterId, DSQLClient& client) {
-        GetClusterRequest request;
-        request.SetIdentifier(clusterId);
-        GetClusterOutcome outcome = client.GetCluster(request);
-        ClusterStatus status = ClusterStatus::NOT_SET;
-    
-        if (outcome.IsSuccess()) {
-            const auto& cluster = outcome.GetResult();
-            status = cluster.GetStatus();
-        } else {
-            std::cerr << "Get operation failed: " << outcome.GetError().GetMessage() << std::endl;
+    /**
+     * Retrieves information about a cluster in Amazon Aurora DSQL
+     */
+    GetClusterResult GetCluster(const Aws::String& region, const Aws::String& identifier) {
+        // Create client for the specified region
+        DSQL::DSQLClientConfiguration clientConfig;
+        clientConfig.region = region;
+        DSQL::DSQLClient client(clientConfig);
+        
+        // Get the cluster
+        GetClusterRequest getClusterRequest;
+        getClusterRequest.SetIdentifier(identifier);
+        
+        auto getOutcome = client.GetCluster(getClusterRequest);
+        if (!getOutcome.IsSuccess()) {
+            std::cerr << "Failed to retrieve cluster " << identifier << " in " << region << ": " 
+                      << getOutcome.GetError().GetMessage() << std::endl;
+            throw std::runtime_error("Unable to retrieve cluster " + identifier + " in region " + region);
@@ -66,2 +78,2 @@ Use the following example to get information about a single or a multi-Region cl
-        std::cout << "Cluster Status: " << ClusterStatusMapper::GetNameForClusterStatus(status) << std::endl;
-        return status;
+        
+        return getOutcome.GetResult();
@@ -73,3 +85,5 @@ Use the following example to get information about a single or a multi-Region cl
-        DSQLClientConfiguration clientConfig;
-    
-        clientConfig.region = "us-east-1";
+        {
+            try {
+                // Define region and cluster ID
+                Aws::String region = "us-east-1";
+                Aws::String clusterId = "<your cluster id>";
@@ -77,2 +91 @@ Use the following example to get information about a single or a multi-Region cl
-        DSQLClient client(clientConfig);
-        String clusterId = "foo0bar1baz2quux3quuux4";
+                auto cluster = GetCluster(region, clusterId);
@@ -80 +93,9 @@ Use the following example to get information about a single or a multi-Region cl
-        getCluster(clusterId, client);
+                // Print cluster details
+                std::cout << "Cluster Details:" << std::endl;
+                std::cout << "ARN: " << cluster.GetArn() << std::endl;
+                std::cout << "Status: " << ClusterStatusMapper::GetNameForClusterStatus(cluster.GetStatus()) << std::endl;
+            }
+            catch (const std::exception& e) {
+                std::cerr << "Error: " << e.what() << std::endl;
+            }
+        }
@@ -92,2 +114,5 @@ To get information about a single or multi-Region cluster, use the following exa
-    import { DSQLClient } from "@aws-sdk/client-dsql";
-    import { GetClusterCommand } from "@aws-sdk/client-dsql";
+    import { DSQLClient, GetClusterCommand } from "@aws-sdk/client-dsql";
+    
+    async function getCluster(region, clusterId) {
+    
+      const client = new DSQLClient({ region });
@@ -95 +119,0 @@ To get information about a single or multi-Region cluster, use the following exa
-    async function getCluster(clusterId, client) {
@@ -105,2 +128,0 @@ To get information about a single or multi-Region cluster, use the following exa
-          } else {
-            console.error("Unable to poll cluster status:", error.message);
@@ -114,6 +136 @@ To get information about a single or multi-Region cluster, use the following exa
-        const client = new DSQLClient({ region });
-    
-        const clusterId = "foo0bar1baz2quux3quuux4";
-    
-        const response = await getCluster(clusterId, client); 
-        console.log("Cluster Status:", response.status);
+      const clusterId = "<CLUSTER_ID>";
@@ -120,0 +138,2 @@ To get information about a single or multi-Region cluster, use the following exa
+      const response = await getCluster(region, clusterId);
+      console.log("Cluster: ", response);
@@ -123 +142 @@ To get information about a single or multi-Region cluster, use the following exa
-    main()
+    main();
@@ -131,0 +151,2 @@ The following example lets you get information about a single or multi-Region cl
+    package org.example;
+    
@@ -133,3 +153,0 @@ The following example lets you get information about a single or multi-Region cl
-    import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration;
-    import software.amazon.awssdk.core.retry.RetryMode;
-    import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient;
@@ -137 +154,0 @@ The following example lets you get information about a single or multi-Region cl
-    import software.amazon.awssdk.retries.StandardRetryStrategy;
@@ -139 +155,0 @@ The following example lets you get information about a single or multi-Region cl
-    import software.amazon.awssdk.services.dsql.model.GetClusterRequest;
@@ -143,2 +158,0 @@ The following example lets you get information about a single or multi-Region cl
-    import java.net.URI;
-    
@@ -147,0 +163 @@ The following example lets you get information about a single or multi-Region cl
+            String clusterId = "<your cluster id>";
@@ -149,4 +165 @@ The following example lets you get information about a single or multi-Region cl
-            ClientOverrideConfiguration clientOverrideConfiguration = ClientOverrideConfiguration.builder()
-                    .retryStrategy(StandardRetryStrategy.builder().build())
-                    .build();
-    
+            try (
@@ -154,2 +166,0 @@ The following example lets you get information about a single or multi-Region cl
-                    .httpClient(UrlConnectionHttpClient.create())
-                    .overrideConfiguration(clientOverrideConfiguration)
@@ -158,20 +169,6 @@ The following example lets you get information about a single or multi-Region cl
-                    .build();
-    
-            String cluster_id = "foo0bar1baz2quux3quuux4";
-    
-            GetClusterResponse response = getCluster(cluster_id, client);
-            System.out.println("cluster status: " + response.status());
-        }
-    
-        public static GetClusterResponse getCluster(String cluster_id, DsqlClient client) {
-            GetClusterRequest getClusterRequest = GetClusterRequest.builder()
-                    .identifier(cluster_id)
-                    .build();
-            try {
-                return client.getCluster(getClusterRequest);
-            } catch (ResourceNotFoundException rnfe) {
-                System.out.println("Cluster id is not found / deleted");
-                throw rnfe;
-            } catch (Exception e) {
-                System.out.println(("Unable to poll cluster status: " + e.getMessage()));
-                throw e;
+                        .build()
+            ) {
+                GetClusterResponse cluster = client.getCluster(r -> r.identifier(clusterId));
+                System.out.println(cluster);
+            } catch (ResourceNotFoundException e) {
+                System.out.printf("Cluster %s not found in %s%n", clusterId, region);
@@ -190 +186,0 @@ The following example lets you get information about a single or multi-Region cl
-    use aws_sdk_dsql::{config::{BehaviorVersion, Region}, Client, Config};
@@ -191,0 +188,4 @@ The following example lets you get information about a single or multi-Region cl
+    use aws_sdk_dsql::{
+        Client, Config,
+        config::{BehaviorVersion, Region},
+    };
@@ -200,3 +200 @@ The following example lets you get information about a single or multi-Region cl
-        let credentials = sdk_defaults
-            .credentials_provider()
-            .unwrap();
+        let credentials = sdk_defaults.credentials_provider().unwrap();
@@ -213,5 +211,2 @@ The following example lets you get information about a single or multi-Region cl
-    // Get a ClusterResource from DSQL cluster identifier
-    pub async fn get_cluster(
-        region: &'static str,
-        identifier: String,
-    ) -> GetClusterOutput {
+    /// Get a ClusterResource from DSQL cluster identifier
+    pub async fn get_cluster(region: &'static str, identifier: &'static str) -> GetClusterOutput {
@@ -231 +226,2 @@ The following example lets you get information about a single or multi-Region cl
-        get_cluster(region, "<your cluster id>".to_owned()).await;
+        let cluster = get_cluster(region, "<your cluster id>").await;
+        println!("{:#?}", cluster);
@@ -243,2 +239,2 @@ The following example lets you get information about a single or multi-Region cl
-    require 'aws-sdk-core'
-    require 'aws-sdk-dsql'
+    require "aws-sdk-dsql"