

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

# 6단계: 구성 요소 배포
<a name="deploy-first-component"></a>

AWS IoT Greengrass를 통해 개별 디바이스 또는 디바이스 그룹에 구성 요소를 배포할 수 있습니다. 구성 요소를 배포하면 AWS IoT Greengrass에서는 대상 디바이스마다 해당 구성 요소의 소프트웨어가 설치 및 실행됩니다. 구성 요소마다 배포할 구성 요소와 배포할 구성 업데이트를 지정합니다. 배포 대상인 디바이스로 배포가 롤아웃되는 방식을 제어할 수도 있습니다. 자세한 내용은 [디바이스에 AWS IoT Greengrass 구성 요소 배포](manage-deployments.md) 섹션을 참조하세요.

이 섹션에서는 Hello World 구성 요소를 Greengrass 코어 디바이스에 다시 배포합니다.

## 구성 요소를 배포하는 방법(콘솔)
<a name="deploy-first-component-console"></a>

1. [AWS IoT Greengrass 콘솔](https://console.aws.amazon.com/greengrass) 탐색 메뉴에서 **구성 요소**를 선택합니다.

1. **구성 요소** 페이지의 **내 구성 요소** 탭에서 **com.example.HelloWorld**를 선택합니다.

1. **com.example.HelloWorld** 페이지에서 **배포**를 선택합니다.

1. **배포에 추가**에서 **새 배포 생성**과 **다음**을 차례로 선택합니다.

1. **대상 지정** 페이지에서 다음 작업을 수행합니다.

   1. **이름(Name)** 상자에 **Deployment for MyGreengrassCore**를 입력합니다.

   1. **배포 대상**에는 **코어 디바이스**와 코어 디바이스의 AWS IoT 사물 이름을 선택합니다. 이 자습서에서는 기본값이 *MyGreengrassCore*입니다.

   1. **다음**을 선택합니다.

1. **구성 요소 선택** 페이지의 **내 구성 요소**에서 **com.example.HelloWorld** 구성 요소가 선택되었는지 확인하고 **다음**을 선택합니다.

1. **구성 요소 구성** 페이지에서 **com.example.HelloWorld**를 선택하고 다음을 수행합니다.

   1. **구성 요소 구성**을 선택합니다.

   1. **구성 업데이트** 아래에 있는 **병합할 구성**에 다음 구성을 입력합니다.

      ```
      {
        "Message": "universe"
      }
      ```

      이 구성 업데이트에서는 이 배포의 디바이스에 대해 Hello World `Message` 파라미터가 `universe`로 설정됩니다.

   1. **확인**을 선택합니다.

   1. **다음**을 선택합니다.

1. **고급 설정 구성** 페이지에서 기본 구성 설정을 유지하고 **다음**을 선택합니다.

1. **검토** 페이지에서 **배포**를 선택합니다.

1. <a name="getting-started-verify-cloud-deployment-step"></a>배포가 완료되었는지 확인합니다. 배포를 완료하는 데 몇 분 정도 걸릴 수 있습니다. Hello World 로그를 점검하여 변경을 확인합니다. Greengrass 코어 디바이스에서 다음 명령을 실행합니다.

------
#### [ Linux or Unix ]

   ```
   sudo tail -f /greengrass/v2/logs/com.example.HelloWorld.log
   ```

------
#### [ Windows Command Prompt (CMD) ]

   ```
   type C:\greengrass\v2\\logs\\com.example.HelloWorld.log
   ```

------
#### [ PowerShell ]

   ```
   gc C:\greengrass\v2\\logs\\com.example.HelloWorld.log -Tail 10 -Wait
   ```

------

   다음 예제와 비슷한 메시지가 표시되어야 합니다.

   ```
   Hello, universe! Greetings from your first Greengrass component.
   ```
**참고**  
로그 메시지가 변경되지 않으면 배포에 실패했거나 코어 디바이스에 도달하지 못한 것입니다. 코어 디바이스가 인터넷에 연결되어 있지 않거나 S3 버킷에서 아티팩트를 검색할 권한이 없으면 이 문제가 발생할 수 있습니다. 코어 디바이스에서 다음 명령을 실행하여 AWS IoT Greengrass 코어 소프트웨어 로그 파일을 확인합니다. 이 파일에는 Greengrass 코어 디바이스의 배포 서비스의 로그가 포함되어 있습니다.  

   ```
   sudo tail -f /greengrass/v2/logs/greengrass.log
   ```

   ```
   type C:\greengrass\v2\\logs\\greengrass.log
   ```
<a name="windows-cmd-type-observe-logs"></a>`type` 명령에서는 파일의 내용이 터미널이 기록됩니다. 이 명령을 여러 번 실행하여 파일의 변경 사항을 관찰합니다.

   ```
   gc C:\greengrass\v2\\logs\\greengrass.log -Tail 10 -Wait
   ```
자세한 내용은 [문제 해결 AWS IoT Greengrass V2](troubleshooting.md) 섹션을 참조하세요.

## 구성 요소 배포(AWS CLI)
<a name="deploy-first-component-cli"></a>

**Hello World 구성 요소를 배포하려면**

1. 개발 컴퓨터에서 `hello-world-deployment.json`이라는 파일을 생성하고 다음 JSON을 파일로 복사합니다. 이 파일에서는 배포되는 구성 요소와 구성이 정의됩니다.

   ```
   {
     "components": {
       "com.example.HelloWorld": {
         "componentVersion": "1.0.0",
         "configurationUpdate": {
           "merge": "{\"Message\":\"universe\"}"
         }
       }
     }
   }
   ```

   이 구성 파일에서는 이전 절차에서 개발하고 게시한 Hello World 구성 요소의 `1.0.0` 버전 배포가 지정됩니다. `configurationUpdate`에서는 JSON에서 인코딩된 문자열로 구성 요소 구성 병합이 지정됩니다. 이 구성 업데이트에서는 이 배포의 디바이스에 대해 Hello World `Message` 파라미터가 `universe`로 설정됩니다.

1. 다음 명령을 실행하여 Greengrass 코어 디바이스에 구성 요소를 배포합니다. 개별 디바이스인 사물 또는 디바이스 그룹인 사물 그룹에 배포할 수 있습니다. 코어의 AWS IoT 사물 이름으로 *MyGreengrassCore*를 바꿉니다.

------
#### [ Linux or Unix ]

   ```
   aws greengrassv2 create-deployment \
     --target-arn "arn:aws:iot:region:account-id:thing/MyGreengrassCore" \
     --cli-input-json file://hello-world-deployment.json
   ```

------
#### [ Windows Command Prompt (CMD) ]

   ```
   aws greengrassv2 create-deployment ^
     --target-arn "arn:aws:iot:region:account-id:thing/MyGreengrassCore" ^
     --cli-input-json file://hello-world-deployment.json
   ```

------
#### [ PowerShell ]

   ```
   aws greengrassv2 create-deployment `
     --target-arn "arn:aws:iot:region:account-id:thing/MyGreengrassCore" `
     --cli-input-json file://hello-world-deployment.json
   ```

------

   다음 예제 출력과 비슷한 출력이 명령에서 반환됩니다.

   ```
   {
     "deploymentId": "deb69c37-314a-4369-a6a1-3dff9fce73a9",
     "iotJobId": "b5d92151-6348-4941-8603-bdbfb3e02b75",
     "iotJobArn": "arn:aws:iot:region:account-id:job/b5d92151-6348-4941-8603-bdbfb3e02b75"
   }
   ```

1. <a name="getting-started-verify-cloud-deployment-step"></a>배포가 완료되었는지 확인합니다. 배포를 완료하는 데 몇 분 정도 걸릴 수 있습니다. Hello World 로그를 점검하여 변경을 확인합니다. Greengrass 코어 디바이스에서 다음 명령을 실행합니다.

------
#### [ Linux or Unix ]

   ```
   sudo tail -f /greengrass/v2/logs/com.example.HelloWorld.log
   ```

------
#### [ Windows Command Prompt (CMD) ]

   ```
   type C:\greengrass\v2\\logs\\com.example.HelloWorld.log
   ```

------
#### [ PowerShell ]

   ```
   gc C:\greengrass\v2\\logs\\com.example.HelloWorld.log -Tail 10 -Wait
   ```

------

   다음 예제와 비슷한 메시지가 표시되어야 합니다.

   ```
   Hello, universe! Greetings from your first Greengrass component.
   ```
**참고**  
로그 메시지가 변경되지 않으면 배포에 실패했거나 코어 디바이스에 도달하지 못한 것입니다. 코어 디바이스가 인터넷에 연결되어 있지 않거나 S3 버킷에서 아티팩트를 검색할 권한이 없으면 이 문제가 발생할 수 있습니다. 코어 디바이스에서 다음 명령을 실행하여 AWS IoT Greengrass 코어 소프트웨어 로그 파일을 확인합니다. 이 파일에는 Greengrass 코어 디바이스의 배포 서비스의 로그가 포함되어 있습니다.  

   ```
   sudo tail -f /greengrass/v2/logs/greengrass.log
   ```

   ```
   type C:\greengrass\v2\\logs\\greengrass.log
   ```
<a name="windows-cmd-type-observe-logs"></a>`type` 명령에서는 파일의 내용이 터미널이 기록됩니다. 이 명령을 여러 번 실행하여 파일의 변경 사항을 관찰합니다.

   ```
   gc C:\greengrass\v2\\logs\\greengrass.log -Tail 10 -Wait
   ```
자세한 내용은 [문제 해결 AWS IoT Greengrass V2](troubleshooting.md) 섹션을 참조하세요.