

# AWS CLI의 명령 구조
<a name="cli-usage-commandstructure"></a>

이 주제에서는 AWS Command Line Interface(AWS CLI) 명령을 구성하는 방법과 wait 명령을 사용하는 방법에 대해 설명합니다.

**Topics**
+ [명령 구조](#cli-usage-commandstructure-structure.title)
+ [wait 명령](#cli-usage-commandstructure-wait)

## 명령 구조
<a name="cli-usage-commandstructure-structure.title"></a>

AWS CLI는 다음 순서로 지정되어야 하는 명령줄에서 멀티파트 구조를 사용합니다.

1. `aws` 프로그램에 대한 기본 호출.

1. 최상위 *명령*: 일반적으로 AWS에서 지원하는 AWS CLI 서비스에 해당합니다.

1. 어떤 작업을 수행할지 지정하는 *하위 명령* 입니다.

1. 작업에 필요한 일반 AWS CLI 옵션 또는 파라미터입니다. 처음 세 개 파트를 따르기만 하면 어떤 순서로든 지정할 수 있습니다. 독점적인 파라미터를 여러 번 지정하면 *마지막 값*만 적용됩니다.

```
$ aws <command> <subcommand> [options and parameters]
```

파라미터는 숫자, 문자열, 목록, 맵, JSON 구조와 같은 다양한 유형의 입력 값을 가져올 수 있습니다. 무엇이 지원되는지는 지정하는 명령 및 하위 명령에 따라 달라집니다.

### 예시
<a name="cli-usage-commandstructure-structure-example"></a>

**Amazon S3**

다음 예제에서는 모든 Amazon S3 버킷을 나열합니다.

```
$ aws s3 ls
2018-12-11 17:08:50 amzn-s3-demo-bucket1
2018-12-14 14:55:44 amzn-s3-demo-bucket2
```

Amazon S3 명령에 대한 자세한 내용은 *AWS CLI 명령 참조*에서 [https://docs.aws.amazon.com/cli/latest/reference/s3/index.html](https://docs.aws.amazon.com/cli/latest/reference/s3/index.html) 섹션을 참조하세요.

**AWS CloudFormation**

다음 [https://docs.aws.amazon.com/cli/latest/reference/cloudformation/create-change-set.html](https://docs.aws.amazon.com/cli/latest/reference/cloudformation/create-change-set.html)명령 예제에서는 cloudformation 스택 이름을 *my-change-set*로 변경합니다.

```
$ aws cloudformation create-change-set --stack-name my-stack --change-set-name my-change-set
```

AWS CloudFormation 명령에 대한 자세한 내용은 *AWS CLI 명령 참조*의 [https://docs.aws.amazon.com/cli/latest/reference/cloudformation/index.html](https://docs.aws.amazon.com/cli/latest/reference/cloudformation/index.html) 섹션을 참조하세요.

## wait 명령
<a name="cli-usage-commandstructure-wait"></a>

일부 AWS 서비스에는 사용 가능한 `wait` 명령이 있습니다. `aws wait`를 사용하는 명령은 일반적으로 명령이 완료될 때까지 기다린 후 다음 단계로 넘어갑니다. 이는 wait 명령이 실패할 경우 후속 단계로 이동하지 않도록 wait 명령을 사용할 수 있으므로 멀티파트 명령 또는 스크립팅에 특히 유용합니다.

AWS CLI는 다음 순서로 지정되어야 하는 `wait` 명령의 경우 명령줄에서 멀티파트 구조를 사용합니다.

1. `aws` 프로그램에 대한 기본 호출.

1. 최상위 *명령*: 일반적으로 AWS에서 지원하는 AWS CLI 서비스에 해당합니다.

1. `wait` 명령.

1. 어떤 작업을 수행할지 지정하는 *하위 명령* 입니다.

1. 작업에 필요한 일반 CLI 옵션 또는 파라미터입니다. 처음 세 개 파트를 따르기만 하면 어떤 순서로든 지정할 수 있습니다. 독점적인 파라미터를 여러 번 지정하면 *마지막 값*만 적용됩니다.

```
$ aws <command> wait <subcommand> [options and parameters]
```

파라미터는 숫자, 문자열, 목록, 맵, JSON 구조와 같은 다양한 유형의 입력 값을 가져올 수 있습니다. 무엇이 지원되는지는 지정하는 명령 및 하위 명령에 따라 달라집니다.

**참고**  
모든 AWS 서비스가 `wait` 명령을 지원하는 것은 아닙니다. 서비스가 `wait` 명령을 지원하는지 확인하려면 [AWS CLI 버전 2 참조 가이드](https://docs.aws.amazon.com/cli/latest/reference/index.html)를 참조하세요.

### 예시
<a name="cli-usage-commandstructure-wait-example"></a>

**AWS CloudFormation**

다음 [https://docs.aws.amazon.com/cli/latest/reference/cloudformation/wait/change-set-create-complete.html](https://docs.aws.amazon.com/cli/latest/reference/cloudformation/wait/change-set-create-complete.html) 명령 예제는 *my-stack* 스택의 *my-change-set* 변경 세트가 실행될 준비가 되었음을 확인한 후에만 일시 중지하고 다시 시작합니다.

```
$ aws cloudformation wait change-set-create-complete --stack-name my-stack --change-set-name my-change-set
```

AWS CloudFormation `wait` 명령에 대한 자세한 내용은 *AWS CLI 명령 참조*의 [https://docs.aws.amazon.com/cli/latest/reference/cloudformation/wait/index.html](https://docs.aws.amazon.com/cli/latest/reference/cloudformation/wait/index.html) 단원을 참조하세요.

**AWS CodeDeploy**

다음 [https://docs.aws.amazon.com/cli/latest/reference/cloudformation/wait/change-set-create-complete.html](https://docs.aws.amazon.com/cli/latest/reference/cloudformation/wait/change-set-create-complete.html) 명령 예제는 *d-A1B2C3111* 배포가 성공적으로 완료될 때까지 일시 중지합니다.

```
$ aws deploy wait deployment-successful --deployment-id d-A1B2C3111
```

AWS CodeDeploy `wait` 명령에 대한 자세한 내용은 *AWS CLI 명령 참조*의 [https://docs.aws.amazon.com/cli/latest/reference/cloudformation/wait/index.html](https://docs.aws.amazon.com/cli/latest/reference/cloudformation/wait/index.html) 섹션을 참조하세요.