Doc AWS SDK Examples リポジトリには、他にも SDK の例があります。 AWS
翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
AWS を使用して Amazon Redshift クラスターを変更する
以下のコード例は、Amazon Redshift クラスターを変更する方法を示しています。
- CLI
-
- AWS CLI
-
セキュリティグループを ClusterThis 例に関連付けて、クラスターセキュリティグループを指定された cluster.Command に関連付ける方法を示します。
aws redshift modify-cluster --cluster-identifier mycluster --cluster-security-groups mysecuritygroup
のメンテナンスウィンドウを変更すると、クラスターの週単位の優先メンテナンスウィンドウを、日曜日の午後 11:15 から月曜日の午前 3:15 に終了する最小の 4 時間のウィンドウに変更する方法 ClusterThis が表示されます。
aws redshift modify-cluster --cluster-identifier mycluster --preferred-maintenance-window Sun:23:15-Mon:03:15
この ClusterThis 例のマスターパスワードの変更は、クラスターのマスターパスワードを変更する方法を示しています。コマンド:
aws redshift modify-cluster --cluster-identifier mycluster --master-user-password A1b2c3d4
-
API の詳細については、「 コマンドリファレンスModifyCluster
」の「」を参照してください。 AWS CLI
-
- Java
-
- SDK for Java 2.x
-
注記
については、こちらを参照してください GitHub。用例一覧を検索し、AWS コードサンプルリポジトリ
での設定と実行の方法を確認してください。 クラスターを変更します。
public static void modifyCluster(RedshiftClient redshiftClient, String clusterId) { try { ModifyClusterRequest modifyClusterRequest = ModifyClusterRequest.builder() .clusterIdentifier(clusterId) .preferredMaintenanceWindow("wed:07:30-wed:08:00") .build(); ModifyClusterResponse clusterResponse = redshiftClient.modifyCluster(modifyClusterRequest); System.out.println("The modified cluster was successfully modified and has " + clusterResponse.cluster().preferredMaintenanceWindow() + " as the maintenance window"); } catch (RedshiftException e) { System.err.println(e.getMessage()); System.exit(1); } }
-
API の詳細については、「 API リファレンスModifyCluster」の「」を参照してください。 AWS SDK for Java 2.x
-
- JavaScript
-
- SDK for JavaScript (v3)
-
注記
については、こちらを参照してください GitHub。用例一覧を検索し、AWS コード例リポジトリ
での設定と実行の方法を確認してください。 クライアントを作成します。
const { RedshiftClient } = require("@aws-sdk/client-redshift"); // Set the AWS Region. const REGION = "REGION"; //Set the Redshift Service Object const redshiftClient = new RedshiftClient({ region: REGION }); export { redshiftClient };
クラスターを変更します。
// Import required AWS SDK clients and commands for Node.js import { ModifyClusterCommand } from "@aws-sdk/client-redshift"; import { redshiftClient } from "./libs/redshiftClient.js"; // Set the parameters const params = { ClusterIdentifier: "CLUSTER_NAME", MasterUserPassword: "NEW_MASTER_USER_PASSWORD", }; const run = async () => { try { const data = await redshiftClient.send(new ModifyClusterCommand(params)); console.log("Success was modified.", data); return data; // For unit tests. } catch (err) { console.log("Error", err); } }; run();
-
API の詳細については、「 API リファレンスModifyCluster」の「」を参照してください。 AWS SDK for JavaScript
-
- Kotlin
-
- SDK for Kotlin
-
注記
については、こちらを参照してください GitHub。用例一覧を検索し、AWS コードサンプルリポジトリ
での設定と実行の方法を確認してください。 クラスターを変更します。
suspend fun modifyCluster(clusterId: String?) { val modifyClusterRequest = ModifyClusterRequest { clusterIdentifier = clusterId preferredMaintenanceWindow = "wed:07:30-wed:08:00" } RedshiftClient { region = "us-west-2" }.use { redshiftClient -> val clusterResponse = redshiftClient.modifyCluster(modifyClusterRequest) println("The modified cluster was successfully modified and has ${clusterResponse.cluster?.preferredMaintenanceWindow} as the maintenance window") } }
-
API の詳細については、ModifyCluster
AWS「 SDK for Kotlin API リファレンス」の「」を参照してください。
-