AWS SDK または CLI で UpdateComputeEnvironment を使用する - AWS SDK コードサンプル

AWS Doc SDK Examples GitHub リポジトリには、他にも用意されている AWS SDK サンプルがあります。

AWS SDK または CLI で UpdateComputeEnvironment を使用する

次のサンプルコードは、UpdateComputeEnvironment を使用する方法を説明しています。

アクション例は、より大きなプログラムからのコードの抜粋であり、コンテキスト内で実行する必要があります。次のコード例で、このアクションのコンテキストを確認できます。

CLI
AWS CLI

コンピューティング環境を作成する方法

この例では、削除できるように P2OnDemand コンピューティング環境を無効にします。

コマンド:

aws batch update-compute-environment --compute-environment P2OnDemand --state DISABLED

出力:

{ "computeEnvironmentName": "P2OnDemand", "computeEnvironmentArn": "arn:aws:batch:us-east-1:012345678910:compute-environment/P2OnDemand" }
  • API の詳細については、「AWS CLI コマンドリファレンス」の「UpdateComputeEnvironment」を参照してください。

Java
SDK for Java 2.x
注記

GitHub には、その他のリソースもあります。AWS コード例リポジトリで完全な例を見つけて、設定と実行の方法を確認してください。

/** * Disables the specified compute environment asynchronously. * * @param computeEnvironmentName the name of the compute environment to disable * @return a CompletableFuture that completes when the compute environment is disabled */ public CompletableFuture<UpdateComputeEnvironmentResponse> disableComputeEnvironmentAsync(String computeEnvironmentName) { UpdateComputeEnvironmentRequest updateRequest = UpdateComputeEnvironmentRequest.builder() .computeEnvironment(computeEnvironmentName) .state(CEState.DISABLED) .build(); CompletableFuture<UpdateComputeEnvironmentResponse> responseFuture = getAsyncClient().updateComputeEnvironment(updateRequest); responseFuture.whenComplete((response, ex) -> { if (ex != null) { throw new RuntimeException("Failed to disable compute environment: " + ex.getMessage(), ex); } }); return responseFuture; }
  • API の詳細については、「AWS SDK for Java 2.x API リファレンス」の「UpdateComputeEnvironment」を参照してください。