

Doc AWS SDK 예제 GitHub 리포지토리에서 더 많은 SDK 예제를 사용할 수 있습니다. [AWS](https://github.com/awsdocs/aws-doc-sdk-examples) 

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# Tools for PowerShell V5를 사용한 Amazon ECS 예제
<a name="powershell_5_ecs_code_examples"></a>

다음 코드 예제에서는 Amazon ECS에서 AWS Tools for PowerShell V5를 사용하여 작업을 수행하고 일반적인 시나리오를 구현하는 방법을 보여줍니다.

*작업*은 대규모 프로그램에서 발췌한 코드이며 컨텍스트에 맞춰 실행해야 합니다. 작업은 개별 서비스 함수를 직접적으로 호출하는 방법을 보여주며 관련 시나리오의 컨텍스트에 맞는 작업을 볼 수 있습니다.

각 예시에는 전체 소스 코드에 대한 링크가 포함되어 있으며, 여기에서 컨텍스트에 맞춰 코드를 설정하고 실행하는 방법에 대한 지침을 찾을 수 있습니다.

**Topics**
+ [작업](#actions)

## 작업
<a name="actions"></a>

### `Get-ECSClusterDetail`
<a name="ecs_DescribeClusters_powershell_5_topic"></a>

다음 코드 예시는 `Get-ECSClusterDetail`의 사용 방법을 보여줍니다.

**Tools for PowerShell V5**  
**예제 1: 이 cmdlet은 하나 이상의 ECS 클러스터를 설명합니다.**  

```
Get-ECSClusterDetail -Cluster "LAB-ECS-CL" -Include SETTINGS | Select-Object *
```
**출력:**  

```
LoggedAt         : 12/27/2019 9:27:41 PM
Clusters         : {LAB-ECS-CL}
Failures         : {}
ResponseMetadata : Amazon.Runtime.ResponseMetadata
ContentLength    : 396
HttpStatusCode   : OK
```
+  API 세부 정보는 *AWS Tools for PowerShell Cmdlet 참조(V5)*의 [DescribeClusters](https://docs.aws.amazon.com/powershell/v5/reference)를 참조하세요.

### `Get-ECSClusterList`
<a name="ecs_ListClusters_powershell_5_topic"></a>

다음 코드 예시는 `Get-ECSClusterList`의 사용 방법을 보여줍니다.

**Tools for PowerShell V5**  
**예제 1: 이 cmdlet은 기존 ECS 클러스터 목록을 반환합니다.**  

```
Get-ECSClusterList
```
**출력:**  

```
arn:aws:ecs:us-west-2:012345678912:cluster/LAB-ECS-CL
arn:aws:ecs:us-west-2:012345678912:cluster/LAB-ECS
```
+  API 세부 정보는 *AWS Tools for PowerShell Cmdlet 참조(V5)*의 [ListClusters](https://docs.aws.amazon.com/powershell/v5/reference)를 참조하세요.

### `Get-ECSClusterService`
<a name="ecs_ListServices_powershell_5_topic"></a>

다음 코드 예시는 `Get-ECSClusterService`의 사용 방법을 보여줍니다.

**Tools for PowerShell V5**  
**예제 1: 이 예제에서는 기본 클러스터에서 실행 중인 모든 서비스를 나열합니다.**  

```
Get-ECSClusterService
```
**예제 2: 이 예제에서는 지정된 클러스터에서 실행 중인 모든 서비스를 나열합니다.**  

```
Get-ECSClusterService -Cluster myCluster
```
+  API 세부 정보는 *AWS Tools for PowerShell Cmdlet 참조(V5)*의 [ListServices](https://docs.aws.amazon.com/powershell/v5/reference)를 참조하세요.

### `Get-ECSService`
<a name="ecs_DescribeServices_powershell_5_topic"></a>

다음 코드 예시는 `Get-ECSService`의 사용 방법을 보여줍니다.

**Tools for PowerShell V5**  
**예제 1: 이 예제에서는 기본 클러스터에서 지정된 서비스의 세부 정보를 검색하는 방법을 보여줍니다.**  

```
Get-ECSService -Service my-hhtp-service
```
**예제 2: 이 예제에서는 명명된 클러스터에서 실행되는 지정된 서비스의 세부 정보를 검색하는 방법을 보여줍니다.**  

```
Get-ECSService -Cluster myCluster -Service my-hhtp-service
```
+  API 세부 정보는 *AWS Tools for PowerShell Cmdlet 참조(V5)*의 [DescribeServices](https://docs.aws.amazon.com/powershell/v5/reference)를 참조하세요.

### `New-ECSCluster`
<a name="ecs_CreateCluster_powershell_5_topic"></a>

다음 코드 예시는 `New-ECSCluster`의 사용 방법을 보여줍니다.

**Tools for PowerShell V5**  
**예제 1: 이 cmdlet은 새 Amazon ECS 클러스터를 생성합니다. **   

```
New-ECSCluster -ClusterName "LAB-ECS-CL" -Setting @{Name="containerInsights"; Value="enabled"}
```
**출력:**  

```
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 참조(V5)*의 [CreateCluster](https://docs.aws.amazon.com/powershell/v5/reference)를 참조하세요.

### `New-ECSService`
<a name="ecs_CreateService_powershell_5_topic"></a>

다음 코드 예시는 `New-ECSService`의 사용 방법을 보여줍니다.

**Tools for PowerShell V5**  
**예제 1: 이 예제 명령에서는 `ecs-simple-service`라는 서비스를 기본 클러스터에 생성합니다. 이 서비스는 `ecs-demo` 태스크 정의를 사용하며 태스크의 인스턴스화 10회를 유지 관리합니다.**  

```
New-ECSService -ServiceName ecs-simple-service -TaskDefinition ecs-demo -DesiredCount 10
```
**예제 2: 이 예제 명령에서는 `ecs-simple-service`라는 기본 클러스터의 로드 밸런서 뒤에 서비스를 생성합니다. 이 서비스는 `ecs-demo` 태스크 정의를 사용하며 태스크의 인스턴스화 10회를 유지 관리합니다.**  

```
$lb = @{
    LoadBalancerName = "EC2Contai-EcsElast-S06278JGSJCM"
    ContainerName = "simple-demo"
    ContainerPort = 80
}        
New-ECSService -ServiceName ecs-simple-service -TaskDefinition ecs-demo -DesiredCount 10 -LoadBalancer $lb
```
+  API 세부 정보는 *AWS Tools for PowerShell Cmdlet 참조(V5)*의 [CreateService](https://docs.aws.amazon.com/powershell/v5/reference)를 참조하세요.

### `Remove-ECSCluster`
<a name="ecs_DeleteCluster_powershell_5_topic"></a>

다음 코드 예시는 `Remove-ECSCluster`의 사용 방법을 보여줍니다.

**Tools for PowerShell V5**  
**예제 1: 이 cmdlet은 지정된 ECS 클러스터를 삭제합니다. 삭제하기 전에 이 클러스터에서 모든 컨테이너 인스턴스의 등록을 취소해야 합니다. **   

```
Remove-ECSCluster -Cluster "LAB-ECS"
```
**출력:**  

```
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
```
+  API 세부 정보는 *AWS Tools for PowerShell Cmdlet 참조(V5)*의 [DeleteCluster](https://docs.aws.amazon.com/powershell/v5/reference)를 참조하세요.

### `Remove-ECSService`
<a name="ecs_DeleteService_powershell_5_topic"></a>

다음 코드 예시는 `Remove-ECSService`의 사용 방법을 보여줍니다.

**Tools for PowerShell V5**  
**예제 1: 기본 클러스터에서 'my-http-service'라는 서비스를 삭제합니다. 서비스를 삭제하려면 먼저 원하는 개수와 실행 개수가 0이어야 합니다. 명령이 실행되기 전에 확인 프롬프트가 표시됩니다. 확인 프롬프트를 우회하려면 명령에 -Force 스위치를 추가합니다.**  

```
Remove-ECSService -Service my-http-service
```
**예제 2: 명명된 클러스터에서 'my-http-service'라는 서비스를 삭제합니다.**  

```
Remove-ECSService -Cluster myCluster -Service my-http-service
```
+  API 세부 정보는 *AWS Tools for PowerShell Cmdlet 참조(V5)*의 [DeleteService](https://docs.aws.amazon.com/powershell/v5/reference)를 참조하세요.

### `Update-ECSClusterSetting`
<a name="ecs_UpdateClusterSettings_powershell_5_topic"></a>

다음 코드 예시는 `Update-ECSClusterSetting`의 사용 방법을 보여줍니다.

**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 참조(V5)*의 [UpdateClusterSettings](https://docs.aws.amazon.com/powershell/v5/reference)을 참조하세요.

### `Update-ECSService`
<a name="ecs_UpdateService_powershell_5_topic"></a>

다음 코드 예시는 `Update-ECSService`의 사용 방법을 보여줍니다.

**Tools for PowerShell V5**  
**예제 1: 이 예제 명령에서는 `amazon-ecs-sample` 태스크 정의를 사용하도록 `my-http-service` 서비스를 업데이트합니다.**  

```
Update-ECSService -Service my-http-service -TaskDefinition amazon-ecs-sample
```
**예제 2: 이 예제 명령에서는 `my-http-service` 서비스의 원하는 개수를 10으로 업데이트합니다.**  

```
Update-ECSService -Service my-http-service -DesiredCount 10
```
+  API 세부 정보는 *AWS Tools for PowerShell Cmdlet 참조(V5)*의 [UpdateService](https://docs.aws.amazon.com/powershell/v5/reference)를 참조하세요.