Usar DeleteCluster com o AWS SDK ou a CLI - Exemplos de código do AWS SDK

Há mais exemplos do AWS SDK disponíveis no repositório do GitHub Documento de Exemplos do AWS SDK.

Usar DeleteCluster com o AWS SDK ou a CLI

Os exemplos de código a seguir mostram como usar o DeleteCluster.

CLI
AWS CLI

Como excluir um cluster vazio

O exemplo de delete-cluster a seguir exclui o cluster vazio especificado.

aws ecs delete-cluster --cluster MyCluster

Saída:

{ "cluster": { "clusterArn": "arn:aws:ecs:us-west-2:123456789012:cluster/MyCluster", "status": "INACTIVE", "clusterName": "MyCluster", "registeredContainerInstancesCount": 0, "pendingTasksCount": 0, "runningTasksCount": 0, "activeServicesCount": 0 "statistics": [], "tags": [] } }

Para obter mais informações, consulte Deleting a Cluster no Guia do desenvolvedor do Amazon ECS.

  • Consulte detalhes da API em DeleteCluster na Referência de comandos da AWS CLI.

PowerShell
Ferramentas para PowerShell V4

Exemplo 1: esse cmdlet exclui o cluster do ECS especificado. Você deve cancelar o registro de todas as instâncias de contêiner desse cluster antes de excluí-las.

Remove-ECSCluster -Cluster "LAB-ECS"

Saída:

Confirm Are you sure you want to perform this action? Performing the operation "Remove-ECSCluster (DeleteCluster)" on target "LAB-ECS". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): Y
  • Consulte detalhes da API em DeleteCluster na Referência de cmdlet do Ferramentas da AWS para PowerShell (V4).

Ferramentas para PowerShell V5

Exemplo 1: esse cmdlet exclui o cluster do ECS especificado. Você deve cancelar o registro de todas as instâncias de contêiner desse cluster antes de excluí-las.

Remove-ECSCluster -Cluster "LAB-ECS"

Saída:

Confirm Are you sure you want to perform this action? Performing the operation "Remove-ECSCluster (DeleteCluster)" on target "LAB-ECS". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): Y
  • Consulte detalhes da API em DeleteCluster na Referência de cmdlet do Ferramentas da AWS para PowerShell (V5).

Rust
SDK para Rust
nota

Há mais no GitHub. Encontre o exemplo completo e veja como configurar e executar no AWS Code Examples Repository.

async fn remove_cluster( client: &aws_sdk_ecs::Client, name: &str, ) -> Result<(), aws_sdk_ecs::Error> { let cluster_deleted = client.delete_cluster().cluster(name).send().await?; println!("cluster deleted: {:?}", cluster_deleted); Ok(()) }
  • Consulte detalhes da API em DeleteCluster na Referência da API AWS SDK para Rust.