

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

# 를 사용하여 AWS 관리형 템플릿에서 작업 생성 AWS CLI
<a name="job-template-manage-cli-create"></a>

 AWS CLI 를 사용하여 AWS 관리형 템플릿에 대한 정보를 가져오고 이러한 템플릿을 사용하여 작업을 생성합니다. 그런 다음 작업을 템플릿으로 저장한 후 사용자 지정 템플릿을 직접 생성할 수 있습니다.

## 관리형 템플릿 나열
<a name="job-template-manage-cli-list"></a>

[https://docs.aws.amazon.com/cli/latest/reference/iot/list-managed-job-templates.html](https://docs.aws.amazon.com/cli/latest/reference/iot/list-managed-job-templates.html) AWS CLI 명령은의 모든 작업 템플릿을 나열합니다 AWS 계정.

```
 aws iot list-managed-job-templates
```

기본적으로이 명령을 실행하면 사용 가능한 모든 AWS 관리형 템플릿과 해당 세부 정보가 표시됩니다.

```
{
    "managedJobTemplates": [
        {
            "templateArn": "arn:aws:iot:region::jobtemplate/AWS-Reboot:1.0",
            "templateName": "AWS-Reboot",
            "description": "A managed job template for rebooting the device.",
            "environments": [
                "LINUX"
            ],
            "templateVersion": "1.0"
        },
        {
            "templateArn": "arn:aws:iot:region::jobtemplate/AWS-Remove-Application:1.0",
            "templateName": "AWS-Remove-Application",
            "description": "A managed job template for uninstalling one or more applications.",
            "environments": [
                "LINUX"
            ],
            "templateVersion": "1.0"
        },
        {
            "templateArn": "arn:aws:iot:region::jobtemplate/AWS-Stop-Application:1.0",
            "templateName": "AWS-Stop-Application",
            "description": "A managed job template for stopping one or more system services.",
            "environments": [
                "LINUX"
            ],
            "templateVersion": "1.0"
        },

        ...

        {
            "templateArn": "arn:aws:iot:us-east-1::jobtemplate/AWS-Restart-Application:1.0",
            "templateName": "AWS-Restart-Application",
            "description": "A managed job template for restarting one or more system services.",
            "environments": [
                "LINUX"
            ],
            "templateVersion": "1.0"
        }
    ]
}
```

자세한 내용은 [ListManagedJobTemplates](https://docs.aws.amazon.com/iot/latest/apireference/API_ListManagedJobTemplates.html)을 참조하세요.

## 관리형 템플릿에 대한 세부 정보 가져오기
<a name="job-template-manage-cli-get"></a>

[https://docs.aws.amazon.com/cli/latest/reference/iot/describe-managed-job-template.html](https://docs.aws.amazon.com/cli/latest/reference/iot/describe-managed-job-template.html) AWS CLI 명령은 지정된 작업 템플릿에 대한 세부 정보를 가져옵니다. 작업 템플릿 이름과 템플릿 버전(선택 사항)을 지정합니다. 템플릿 버전을 지정하지 않으면 미리 정의된 기본 버전이 반환됩니다. 다음은 명령을 실행하여 `AWS-Download-File` 템플릿에 대한 세부 정보를 가져오는 예를 보여줍니다.

```
aws iot describe-managed-job-template \
    --template-name AWS-Download-File
```

이 명령은 템플릿 세부 정보, ARN, 해당 작업 문서 및 템플릿의 입력 파라미터의 키-값 페어 목록인 `documentParameters` 파라미터를 표시합니다. 각 템플릿과 입력 파라미터에 대한 자세한 내용은 [관리형 템플릿 원격 작업 및 작업 문서](job-templates-managed.md#job-template-manage-actions) 섹션을 참조하세요.

**참고**  
이 API를 사용할 때 반환되는 `documentParameters` 객체는 AWS 관리형 템플릿에서 작업을 생성할 때만 사용해야 합니다. 사용자 지정 작업 템플릿에 객체를 사용해서는 안 됩니다. 이 파라미터를 이용하는 방법의 예는 [관리형 템플릿을 사용하여 작업 생성](#job-template-manage-cli-create-job) 섹션을 참조하세요.

```
{
    "templateName": "AWS-Download-File",
    "templateArn": "arn:aws:iot:region::jobtemplate/AWS-Download-File:1.0",
    "description": "A managed job template for downloading a file.",
    "templateVersion": "1.0",
    "environments": [
        "LINUX"
    ],
    "documentParameters": [
        {
            "key": "downloadUrl",
            "description": "URL of file to download.",
            "regex": "(.*?)",
            "example": "http://www.example.com/index.html",
            "optional": false
        },
        {
            "key": "filePath",
            "description": "Path on the device where downloaded file is written.",
            "regex": "(.*?)",
            "example": "/path/to/file",
            "optional": false
        },
        {
            "key": "runAsUser",
            "description": "Execute handler as another user. If not specified, then handler is executed as the same user as device client.",
            "regex": "(.){0,256}",
            "example": "user1",
            "optional": true
        },
        {
            "key": "pathToHandler",
            "description": "Path to handler on the device. If not specified, then device client will use the current working directory.",
            "regex": "(.){0,4096}",
            "example": "/path/to/handler/script",
            "optional": true
        }
    ],
    "document": "{\"version\":\"1.0\",\"steps\":[{\"action\":{\"name\":\"Download-File\",\"type\":\"runHandler\",\"input\":{\"handler\":\"download-file.sh\",\"args\":[\"${aws:iot:parameter:downloadUrl}\",\"${aws:iot:parameter:filePath}\"],\"path\":\"${aws:iot:parameter:pathToHandler}\"},\"runAsUser\":\"${aws:iot:parameter:runAsUser}\"}}]}"
}
```

자세한 내용은 [DescribeManagedJobTemplate](https://docs.aws.amazon.com/iot/latest/apireference/API_DescribeManagedJobTemplate.html)을 참조하세요.

## 관리형 템플릿을 사용하여 작업 생성
<a name="job-template-manage-cli-create-job"></a>

[https://docs.aws.amazon.com/cli/latest/reference/iot/create-job.html](https://docs.aws.amazon.com/cli/latest/reference/iot/create-job.html) AWS CLI 명령을 사용하여 작업 템플릿에서 작업을 생성할 수 있습니다. `thingOne`이라는 디바이스를 대상으로 하고, 작업의 기초로 사용할 관리형 템플릿의 Amazon 리소스 이름(ARN)을 지정합니다. `create-job` 명령의 연결된 파라미터를 전달하여 시간 초과 및 취소 구성과 같은 고급 구성을 재정의할 수 있습니다.

예에서는 `AWS-Download-File` 템플릿을 사용하는 작업을 생성하는 방법을 보여줍니다. 또한 `document-parameters` 파라미터를 사용하여 템플릿의 입력 파라미터를 지정하는 방법을 보여줍니다.

**참고**  
 AWS 관리형 템플릿에서만 `document-parameters` 객체를 사용합니다. 사용자 지정 작업 템플릿에 이 객체를 사용해서는 안 됩니다.

```
aws iot create-job \
   --targets arn:aws:iot:region:account-id:thing/thingOne \ 
   --job-id "new-managed-template-job" \ 
   --job-template-arn arn:aws:iot:region::jobtemplate/AWS-Download-File:1.0 \
   --document-parameters downloadUrl=https://example.com/index.html,filePath=path/to/file
```

여기서 각 항목은 다음과 같습니다.
+ *region*은 입니다 AWS 리전.
+ *account-id*은 고유한 AWS 계정 번호입니다.
+ `thingOne`은 작업이 대상으로 지정된 IoT 사물의 이름입니다.
+ *AWS-Download-File:1.0*은 관리형 템플릿의 이름입니다.
+ `https://example.com/index.html`은 파일을 다운로드할 URL입니다.
+ `https://pathto/file/index`는 다운로드한 파일을 저장할 디바이스의 로컬 파일 경로입니다.

다음 명령을 실행하여 `AWS-Download-File` 템플릿에 대한 작업을 생성합니다.

```
{
    "jobArn": "arn:aws:iot:region:account-id:job/new-managed-template-job",
    "jobId": "new-managed-template-job",
    "description": "A managed job template for downloading a file."
}
```

## 관리형 템플릿에서 사용자 지정 작업 템플릿 생성
<a name="job-template-manage-cli-create-jobtemplate"></a>

1. 이전 섹션의 설명에 따라 관리형 템플릿을 사용하여 작업을 생성합니다.

1. 생성한 작업의 ARN을 사용하여 사용자 정의 작업 템플릿을 생성합니다. 자세한 내용은 [기존 작업에서 작업 템플릿 생성](job-templates-cli.md#job-templates-cli-create-from-job) 단원을 참조하십시오.