

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

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

# AWS Proton 를 사용한 예제 AWS CLI
<a name="cli_2_proton_code_examples"></a>

다음 코드 예제에서는와 AWS Command Line Interface 함께를 사용하여 작업을 수행하고 일반적인 시나리오를 구현하는 방법을 보여줍니다 AWS Proton.

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

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

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

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

### `cancel-service-instance-deployment`
<a name="proton_CancelServiceInstanceDeployment_cli_2_topic"></a>

다음 코드 예시에서는 `cancel-service-instance-deployment`의 사용 방법을 보여줍니다.

**AWS CLI**  
**서비스 인스턴스 배포 취소**  
다음 `cancel-service-instance-deployment` 예시에서는 서비스 인스턴스 배포를 취소합니다.  

```
aws proton cancel-service-instance-deployment \
    --service-instance-name "instance-one" \
    --service-name "simple-svc"
```
출력:  

```
{
    "serviceInstance": {
        "arn": "arn:aws:proton:region-id:123456789012:service/simple-svc/service-instance/instance-one",
        "createdAt": "2021-04-02T21:29:59.962000+00:00",
        "deploymentStatus": "CANCELLING",
        "environmentName": "simple-env",
        "lastDeploymentAttemptedAt": "2021-04-02T21:45:15.406000+00:00",
        "lastDeploymentSucceededAt": "2021-04-02T21:38:00.823000+00:00",
        "name": "instance-one",
        "serviceName": "simple-svc",
        "spec": "proton: ServiceSpec\npipeline:\n  my_sample_pipeline_optional_input: abc\n  my_sample_pipeline_required_input: '123'\ninstances:\n- name: my-instance\n  environment: MySimpleEnv\n  spec:\n    my_sample_service_instance_optional_input: def\n    my_sample_service_instance_required_input: '456'\n- name: my-other-instance\n  environment: MySimpleEnv\n  spec:\n    my_sample_service_instance_required_input: '789'\n",
        "templateMajorVersion": "1",
        "templateMinorVersion": "1",
        "templateName": "svc-simple"
    }
}
```
자세한 내용은 * AWS Proton 관리자 안내서*의 [서비스 인스턴스 업데이트](https://docs.aws.amazon.com/proton/latest/adminguide/ag-svc-instance-update.html) 또는 * AWS Proton 사용 설명서*의 [서비스 인스턴스 업데이트를 참조하세요](https://docs.aws.amazon.com/proton/latest/userguide/ug-svc-instance-update.html).  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [CancelServiceInstanceDeployment](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/proton/cancel-service-instance-deployment.html)를 참조하세요.

### `cancel-service-pipeline-deployment`
<a name="proton_CancelServicePipelineDeployment_cli_2_topic"></a>

다음 코드 예시에서는 `cancel-service-pipeline-deployment`의 사용 방법을 보여줍니다.

**AWS CLI**  
**서비스 파이프라인 배포 취소**  
다음 `cancel-service-pipeline-deployment` 예시에서는 서비스 파이프라인 배포를 취소합니다.  

```
aws proton cancel-service-pipeline-deployment \
    --service-name "simple-svc"
```
출력:  

```
{
    "pipeline": {
        "arn": "arn:aws:proton:region-id:123456789012:service/simple-svc/pipeline",
        "createdAt": "2021-04-02T21:29:59.962000+00:00",
        "deploymentStatus": "CANCELLING",
        "lastDeploymentAttemptedAt": "2021-04-02T22:02:45.095000+00:00",
        "lastDeploymentSucceededAt": "2021-04-02T21:39:28.991000+00:00",
        "templateMajorVersion": "1",
        "templateMinorVersion": "1",
        "templateName": "svc-simple"
    }
}
```
자세한 내용은 * AWS Proton 관리자 안내서*의 [서비스 파이프라인 업데이트](https://docs.aws.amazon.com/proton/latest/adminguide/ag-svc-pipeline-update.html) 또는 * AWS Proton 사용 설명서*의 [서비스 파이프라인 업데이트를 참조하세요](https://docs.aws.amazon.com/proton/latest/userguide/ag-svc-pipeline-update.html).  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [CancelServicePipelineDeployment](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/proton/cancel-service-pipeline-deployment.html)를 참조하세요.

### `create-service`
<a name="proton_CreateService_cli_2_topic"></a>

다음 코드 예시에서는 `create-service`의 사용 방법을 보여줍니다.

**AWS CLI**  
**서비스 생성**  
다음 `create-service` 예시에서는 서비스 파이프라인을 사용하여 서비스를 생성합니다.  

```
aws proton create-service \
    --name "MySimpleService" \
    --template-name "fargate-service" \
    --template-major-version "1" \
    --branch-name "mainline" \
    --repository-connection-arn "arn:aws:codestar-connections:region-id:account-id:connection/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111" \
    --repository-id "myorg/myapp" \
    --spec file://spec.yaml
```
`spec.yaml`의 콘텐츠:  

```
proton: ServiceSpec

pipeline:
    my_sample_pipeline_required_input: "hello"
    my_sample_pipeline_optional_input: "bye"

instances:
    - name: "acme-network-dev"
        environment: "ENV_NAME"
        spec:
            my_sample_service_instance_required_input: "hi"
            my_sample_service_instance_optional_input: "ho"
```
출력:  

```
{
    "service": {
        "arn": "arn:aws:proton:region-id:123456789012:service/MySimpleService",
        "createdAt": "2020-11-18T19:50:27.460000+00:00",
        "lastModifiedAt": "2020-11-18T19:50:27.460000+00:00",
        "name": "MySimpleService",
        "repositoryConnectionArn": "arn:aws:codestar-connections:region-id:123456789012connection/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
        "repositoryId": "myorg/myapp",
        "status": "CREATE_IN_PROGRESS",
        "templateName": "fargate-service"
    }
}
```
자세한 내용은 * AWS Proton 관리자 안내서*의 [서비스 생성](https://docs.aws.amazon.com/proton/latest/adminguide/ag-create-svc.html) 및 * AWS Proton 사용 설명서*의 [서비스 생성을 참조하세요](https://docs.aws.amazon.com/proton/latest/userguide/ug-svc-create.html).  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [CreateService](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/proton/create-service.html)를 참조하세요.

### `delete-service`
<a name="proton_DeleteService_cli_2_topic"></a>

다음 코드 예시에서는 `delete-service`의 사용 방법을 보여줍니다.

**AWS CLI**  
**서비스 삭제**  
다음 `delete-service` 예시에서는 서비스를 삭제합니다.  

```
aws proton delete-service \
    --name "simple-svc"
```
출력:  

```
{
    "service": {
        "arn": "arn:aws:proton:region-id:123456789012:service/simple-svc",
        "branchName": "mainline",
        "createdAt": "2020-11-28T22:40:50.512000+00:00",
        "description": "Edit by updating description",
        "lastModifiedAt": "2020-11-29T00:30:39.248000+00:00",
        "name": "simple-svc",
        "repositoryConnectionArn": "arn:aws:codestar-connections:region-id:123456789012:connection/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
        "repositoryId": "myorg/myapp",
        "status": "DELETE_IN_PROGRESS",
        "templateName": "fargate-service"
    }
}
```
자세한 내용은 * AWS Proton 관리자 안내서*의 [서비스 삭제](https://docs.aws.amazon.com/proton/latest/adminguide/ag-svc-delete.html)를 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [DeleteService](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/proton/delete-service.html)를 참조하세요.

### `get-service-instance`
<a name="proton_GetServiceInstance_cli_2_topic"></a>

다음 코드 예시에서는 `get-service-instance`의 사용 방법을 보여줍니다.

**AWS CLI**  
**서비스 인스턴스 세부 정보 가져오기**  
다음 `get-service-instance` 예시에서는 서비스 인스턴스의 세부 데이터를 가져옵니다.  

```
aws proton get-service-instance \
    --name "instance-one" \
    --service-name "simple-svc"
```
출력:  

```
{
    "serviceInstance": {
        "arn": "arn:aws:proton:region-id:123456789012:service/simple-svc/service-instance/instance-one",
        "createdAt": "2020-11-28T22:40:50.512000+00:00",
        "deploymentStatus": "SUCCEEDED",
        "environmentName": "simple-env",
        "lastDeploymentAttemptedAt": "2020-11-28T22:40:50.512000+00:00",
        "lastDeploymentSucceededAt": "2020-11-28T22:40:50.512000+00:00",
        "name": "instance-one",
        "serviceName": "simple-svc",
        "spec": "proton: ServiceSpec\npipeline:\n  my_sample_pipeline_optional_input: hello world\n  my_sample_pipeline_required_input: pipeline up\ninstances:\n- name: instance-one\n  environment: my-simple-env\n  spec:\n    my_sample_service_instance_optional_input: Ola\n    my_sample_service_instance_required_input: Ciao\n",
        "templateMajorVersion": "1",
        "templateMinorVersion": "0",
        "templateName": "svc-simple"
    }
}
```
자세한 내용은 * AWS Proton 관리자 안내서*의 [서비스 데이터 보기](https://docs.aws.amazon.com/proton/latest/adminguide/ag-svc-view.html) 또는 Proton 사용 설명서의 [서비스 데이터 보기를](https://docs.aws.amazon.com/proton/latest/userguide/ug-svc-view.html) 참조하세요. * AWS *   
+  API 세부 정보는 *AWS CLI 명령 참조*의 [GetServiceInstance](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/proton/get-service-instance.html)를 참조하세요.

### `get-service`
<a name="proton_GetService_cli_2_topic"></a>

다음 코드 예시에서는 `get-service`의 사용 방법을 보여줍니다.

**AWS CLI**  
**서비스 세부 정보 가져오기**  
다음 `get-service` 예시에서는 서비스의 세부 데이터를 가져옵니다.  

```
aws proton get-service \
    --name "simple-svc"
```
출력:  

```
{
    "service": {
        "arn": "arn:aws:proton:region-id:123456789012:service/simple-svc",
        "branchName": "mainline",
        "createdAt": "2020-11-28T22:40:50.512000+00:00",
        "lastModifiedAt": "2020-11-28T22:44:51.207000+00:00",
        "name": "simple-svc",
        "pipeline": {
            "arn": "arn:aws:proton:region-id:123456789012:service/simple-svc/pipeline/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
            "createdAt": "2020-11-28T22:40:50.512000+00:00",
            "deploymentStatus": "SUCCEEDED",
            "lastDeploymentAttemptedAt": "2020-11-28T22:40:50.512000+00:00",
            "lastDeploymentSucceededAt": "2020-11-28T22:40:50.512000+00:00",
            "spec": "proton: ServiceSpec\npipeline:\n  my_sample_pipeline_required_input: hello\n  my_sample_pipeline_optional_input: bye\ninstances:\n- name: instance-svc-simple\n  environment: my-simple-env\n  spec:\n    my_sample_service_instance_required_input: hi\n    my_sample_service_instance_optional_input: ho\n",
            "templateMajorVersion": "1",
            "templateMinorVersion": "1",
            "templateName": "svc-simple"
        },
        "repositoryConnectionArn": "arn:aws:codestar-connections:region-id:123456789012:connection/a1b2c3d4-5678-90ab-cdef-EXAMPLE22222",
        "repositoryId": "myorg/myapp",
        "spec": "proton: ServiceSpec\npipeline:\n  my_sample_pipeline_required_input: hello\n  my_sample_pipeline_optional_input: bye\ninstances:\n- name: instance-svc-simple\n  environment: my-simple-env\n  spec:\n    my_sample_service_instance_required_input: hi\n    my_sample_service_instance_optional_input: ho\n",
        "status": "ACTIVE",
        "templateName": "svc-simple"
    }
}
```
자세한 내용은 * AWS Proton 관리자 안내서*의 [서비스 데이터 보기](https://docs.aws.amazon.com/proton/latest/adminguide/ag-svc-view.html) 또는 Proton 사용 설명서의 [서비스 데이터 보기를](https://docs.aws.amazon.com/proton/latest/userguide/ug-svc-view.html) 참조하세요. * AWS *   
+  API 세부 정보는 *AWS CLI 명령 참조*의 [GetService](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/proton/get-service.html)를 참조하세요.

### `list-service-instances`
<a name="proton_ListServiceInstances_cli_2_topic"></a>

다음 코드 예시에서는 `list-service-instances`의 사용 방법을 보여줍니다.

**AWS CLI**  
**예시 1: 모든 서비스 인스턴스 나열**  
다음 `list-service-instances` 예시에서는 서비스 인스턴스를 나열합니다.  

```
aws proton list-service-instances
```
출력:  

```
{
    "serviceInstances": [
        {
            "arn": "arn:aws:proton:region-id:123456789012:service/simple-svc/service-instance/instance-one",
            "createdAt": "2020-11-28T22:40:50.512000+00:00",
            "deploymentStatus": "SUCCEEDED",
            "environmentArn": "arn:aws:proton:region-id:123456789012:environment/simple-env",
            "lastDeploymentAttemptedAt": "2020-11-28T22:40:50.512000+00:00",
            "lastDeploymentSucceededAt": "2020-11-28T22:40:50.512000+00:00",
            "name": "instance-one",
            "serviceName": "simple-svc",
            "templateMajorVersion": "1",
            "templateMinorVersion": "0",
            "templateName": "fargate-service"
        }
    ]
}
```
자세한 내용은 * AWS Proton 관리자 안내서*의 [서비스 인스턴스 데이터 보기](https://docs.aws.amazon.com/proton/latest/adminguide/ag-svc-instance-view.html) 또는 Proton 사용 설명서의 [서비스 인스턴스 데이터 보기를](https://docs.aws.amazon.com/proton/latest/userguide/ag-svc-instance-view.html) 참조하세요. * AWS *   
**예시 2: 지정된 서비스 인스턴스 나열**  
다음 `get-service-instance` 예시에서는 서비스 인스턴스를 가져옵니다.  

```
aws proton get-service-instance \
    --name "instance-one" \
    --service-name "simple-svc"
```
출력:  

```
{
    "serviceInstance": {
        "arn": "arn:aws:proton:region-id:123456789012:service/simple-svc/service-instance/instance-one",
        "createdAt": "2020-11-28T22:40:50.512000+00:00",
        "deploymentStatus": "SUCCEEDED",
        "environmentName": "simple-env",
        "lastDeploymentAttemptedAt": "2020-11-28T22:40:50.512000+00:00",
        "lastDeploymentSucceededAt": "2020-11-28T22:40:50.512000+00:00",
        "name": "instance-one",
        "serviceName": "simple-svc",
        "spec": "proton: ServiceSpec\npipeline:\n  my_sample_pipeline_optional_input: hello world\n  my_sample_pipeline_required_input: pipeline up\ninstances:\n- name: instance-one\n  environment: my-simple-env\n  spec:\n    my_sample_service_instance_optional_input: Ola\n    my_sample_service_instance_required_input: Ciao\n",
        "templateMajorVersion": "1",
        "templateMinorVersion": "0",
        "templateName": "svc-simple"
    }
}
```
자세한 내용은 * AWS Proton 관리자 안내서*의 [서비스 인스턴스 데이터 보기](https://docs.aws.amazon.com/proton/latest/adminguide/ag-svc-instance-view.html) 또는 Proton 사용 설명서의 [서비스 인스턴스 데이터 보기를](https://docs.aws.amazon.com/proton/latest/userguide/ag-svc-instance-view.html) 참조하세요. * AWS *   
+  API 세부 정보는 *AWS CLI 명령 참조*의 [ListServiceInstances](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/proton/list-service-instances.html)를 참조하세요.

### `update-service-instance`
<a name="proton_UpdateServiceInstance_cli_2_topic"></a>

다음 코드 예시에서는 `update-service-instance`의 사용 방법을 보여줍니다.

**AWS CLI**  
**서비스 인스턴스를 새 마이너 버전으로 업데이트**  
다음 `update-service-instance` 예시에서는 서비스 인스턴스를 서비스 템플릿의 새 마이너 버전으로 업데이트하여 'my-other-instance'라는 새 인스턴스를 새로운 필수 입력과 함께 추가합니다.  

```
aws proton update-service-instance \
    --service-name "simple-svc" \
    --spec "file://service-spec.yaml " \
    --template-major-version "1" \
    --template-minor-version "1" \
    --deployment-type "MINOR_VERSION" \
    --name "instance-one"
```
`service-spec.yaml`의 콘텐츠:  

```
proton: ServiceSpec
pipeline:
    my_sample_pipeline_optional_input: "abc"
    my_sample_pipeline_required_input: "123"
instances:
    - name: "instance-one"
        environment: "simple-env"
        spec:
            my_sample_service_instance_optional_input: "def"
            my_sample_service_instance_required_input: "456"
    - name: "my-other-instance"
        environment: "simple-env"
        spec:
            my_sample_service_instance_required_input: "789"
```
출력:  

```
{
    "serviceInstance": {
        "arn": "arn:aws:proton:region-id:123456789012:service/simple-svc/service-instance/instance-one",
        "createdAt": "2021-04-02T21:29:59.962000+00:00",
        "deploymentStatus": "IN_PROGRESS",
        "environmentName": "arn:aws:proton:region-id:123456789012:environment/simple-env",
        "lastDeploymentAttemptedAt": "2021-04-02T21:38:00.823000+00:00",
        "lastDeploymentSucceededAt": "2021-04-02T21:29:59.962000+00:00",
        "name": "instance-one",
        "serviceName": "simple-svc",
        "templateMajorVersion": "1",
        "templateMinorVersion": "0",
        "templateName": "svc-simple"
    }
}
```
자세한 내용은 * AWS Proton 관리자 안내서*의 [서비스 인스턴스 업데이트](https://docs.aws.amazon.com/proton/latest/adminguide/ag-svc-instance-update.html) 또는 * AWS Proton 사용 설명서*의 [서비스 인스턴스 업데이트를 참조하세요](https://docs.aws.amazon.com/proton/latest/userguide/ag-svc-instance-update.html).  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [UpdateServiceInstance](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/proton/update-service-instance.html)를 참조하세요.

### `update-service-pipeline`
<a name="proton_UpdateServicePipeline_cli_2_topic"></a>

다음 코드 예시에서는 `update-service-pipeline`의 사용 방법을 보여줍니다.

**AWS CLI**  
**서비스 파이프라인 업데이트**  
다음 `update-service-pipeline` 예시에서는 서비스 파이프라인을 서비스 템플릿의 새 마이너 버전으로 업데이트합니다.  

```
aws proton update-service-pipeline \
    --service-name "simple-svc" \
    --spec "file://service-spec.yaml" \
    --template-major-version "1" \
    --template-minor-version "1" \
    --deployment-type "MINOR_VERSION"
```
출력:  

```
{
    "pipeline": {
        "arn": "arn:aws:proton:region-id:123456789012:service/simple-svc/pipeline/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
        "createdAt": "2021-04-02T21:29:59.962000+00:00",
        "deploymentStatus": "IN_PROGRESS",
        "lastDeploymentAttemptedAt": "2021-04-02T21:39:28.991000+00:00",
        "lastDeploymentSucceededAt": "2021-04-02T21:29:59.962000+00:00",
        "spec": "proton: ServiceSpec\n\npipeline:\n  my_sample_pipeline_optional_input: \"abc\"\n  my_sample_pipeline_required_input: \"123\"\n\ninstances:\n  - name: \"my-instance\"\n    environment: \"MySimpleEnv\"\n    spec:\n      my_sample_service_instance_optional_input: \"def\"\n      my_sample_service_instance_required_input: \"456\"\n  - name: \"my-other-instance\"\n    environment: \"MySimpleEnv\"\n    spec:\n      my_sample_service_instance_required_input: \"789\"\n",
        "templateMajorVersion": "1",
        "templateMinorVersion": "0",
        "templateName": "svc-simple"
    }
}
```
자세한 내용은 * AWS Proton 관리자 안내서*의 [서비스 파이프라인 업데이트](https://docs.aws.amazon.com/proton/latest/adminguide/ag-svc-pipeline-update.html) 또는 * AWS Proton 사용 설명서*의 [서비스 파이프라인 업데이트를 참조하세요](https://docs.aws.amazon.com/proton/latest/userguide/ag-svc-pipeline-update.html).  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [UpdateServicePipeline](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/proton/update-service-pipeline.html)을 참조하세요.

### `update-service`
<a name="proton_UpdateService_cli_2_topic"></a>

다음 코드 예시에서는 `update-service`의 사용 방법을 보여줍니다.

**AWS CLI**  
**서비스 업데이트**  
다음 `update-service` 예시에서는 서비스 설명을 편집합니다.  

```
aws proton update-service \
    --name "MySimpleService" \
    --description "Edit by updating description"
```
출력:  

```
{
    "service": {
        "arn": "arn:aws:proton:region-id:123456789012:service/MySimpleService",
        "branchName": "mainline",
        "createdAt": "2021-03-12T22:39:42.318000+00:00",
        "description": "Edit by updating description",
        "lastModifiedAt": "2021-03-12T22:44:21.975000+00:00",
        "name": "MySimpleService",
        "repositoryConnectionArn": "arn:aws:codestar-connections:region-id:123456789012:connection/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
        "repositoryId": "myorg/myapp",
        "status": "ACTIVE",
        "templateName": "fargate-service"
    }
}
```
자세한 내용은 * AWS Proton 관리자 안내서*의 [서비스 편집](https://docs.aws.amazon.com/proton/latest/adminguide/ag-svc-update.html) 또는 * AWS Proton 사용 설명서*의 [서비스 편집을](https://docs.aws.amazon.com/proton/latest/userguide/ug-svc-update.html) 참조하세요.  
+  API 세부 정보는 *AWS CLI 명령 참조*의 [UpdateService](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/proton/update-service.html)를 참조하세요.