AWS 文档 SDK 示例
将 UpdateClusterSettings 与 CLI 配合使用
以下代码示例演示如何使用 UpdateClusterSettings。
- CLI
-
- AWS CLI
-
修改集群的设置
以下
update-cluster-settings示例为MyCluster集群启用具有增强型可观测性的 CloudWatch Container Insights。aws ecs update-cluster-settings \ --clusterMyCluster\ --settingsname=containerInsights,value=enhanced输出:
{ "cluster": { "clusterArn": "arn:aws:ecs:us-esat-1:123456789012:cluster/MyCluster", "clusterName": "default", "status": "ACTIVE", "registeredContainerInstancesCount": 0, "runningTasksCount": 0, "pendingTasksCount": 0, "activeServicesCount": 0, "statistics": [], "tags": [], "settings": [ { "name": "containerInsights", "value": "enhanced" } ] } }有关更多信息,请参阅《Amazon ECS 开发人员指南》中的修改账户设置。
-
有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 UpdateClusterSettings
。
-
- PowerShell
-
- Tools for PowerShell V4
-
示例 1:此 cmdlet 修改要用于 ECS 集群的设置。
Update-ECSClusterSetting -Cluster "LAB-ECS-CL" -Setting @{Name="containerInsights"; Value="disabled"}输出:
ActiveServicesCount : 0 Attachments : {} AttachmentsStatus : CapacityProviders : {} ClusterArn : arn:aws:ecs:us-west-2:012345678912:cluster/LAB-ECS-CL ClusterName : LAB-ECS-CL DefaultCapacityProviderStrategy : {} PendingTasksCount : 0 RegisteredContainerInstancesCount : 0 RunningTasksCount : 0 Settings : {containerInsights} Statistics : {} Status : ACTIVE Tags : {}-
有关 API 详细信息,请参阅《AWS Tools for PowerShell Cmdlet Reference (V4)》中的 UpdateClusterSettings。
-
- Tools for PowerShell V5
-
示例 1:此 cmdlet 修改要用于 ECS 集群的设置。
Update-ECSClusterSetting -Cluster "LAB-ECS-CL" -Setting @{Name="containerInsights"; Value="disabled"}输出:
ActiveServicesCount : 0 Attachments : {} AttachmentsStatus : CapacityProviders : {} ClusterArn : arn:aws:ecs:us-west-2:012345678912:cluster/LAB-ECS-CL ClusterName : LAB-ECS-CL DefaultCapacityProviderStrategy : {} PendingTasksCount : 0 RegisteredContainerInstancesCount : 0 RunningTasksCount : 0 Settings : {containerInsights} Statistics : {} Status : ACTIVE Tags : {}-
有关 API 详细信息,请参阅《AWS Tools for PowerShell Cmdlet Reference (V5)》中的 UpdateClusterSettings。
-
ListTasks
UpdateService