

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 使用获取创建OTAUpdate 失败详情 AWS CLI
<a name="ota-create-failure"></a>

如果创建 OTA 更新作业的过程失败，则可以采取一些措施来解决问题。当您创建 OTA 更新任务时，OTA 管理器服务会创建一个 IoT 任务并将其调度到目标设备，此过程还会在您的账户中创建或使用其他类型的 AWS 资源（代码签名任务、 AWS IoT 流、Amazon S3 对象）。遇到的任何错误都可能导致该进程在不创建 AWS IoT 作业的情况下失败。在此故障排除部分，我们提供了有关如何检索失败详细信息的说明。

1. 安装和配置 [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html)。

1. 运行 `aws configure` 并输入以下信息。

   ```
   $ aws configure
   AWS Access Key ID [None]: AccessID
   AWS Secret Access Key [None]: AccessKey
   Default region name [None]: Region
   Default output format [None]: json
   ```

   有关更多信息，请参阅[使用 `aws configure` 进行快速配置](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html#cli-configure-quickstart-config)。

1. 运行：

   ```
   aws iot get-ota-update --ota-update-id ota_update_job_001
   ```

   您在创建 OTA 更新时提供的 ID 在哪里*ota\$1update\$1job\$1001*。

1. 输出如下所示：

   ```
   {
       "otaUpdateInfo": {
           "otaUpdateId": "ota_update_job_001",
           "otaUpdateArn": "arn:aws:iot:region:account_id:otaupdate/ota_update_job_001",
           "creationDate": 1584646864.534,
           "lastModifiedDate": 1584646865.913,
           "targets": [
               "arn:aws:iot:region:account_id:thing/thing_001"
           ],
           "protocols": [
               "MQTT"
           ],
           "awsJobExecutionsRolloutConfig": {},
           "awsJobPresignedUrlConfig": {},
           "targetSelection": "SNAPSHOT",
           "otaUpdateFiles": [
               {
                  "fileName": "/12ds",
                   "fileLocation": {
                       "s3Location": {
                           "bucket": "bucket_name",
                           "key": "demo.bin",
                           "version": "Z7X.TWSAS7JSi4rybc02nMdcE41W1tV3"
                       }
                   },
                   "codeSigning": {
                       "startSigningJobParameter": {
                           "signingProfileParameter": {},
                           "signingProfileName": "signing_profile_name",
                           "destination": {
                               "s3Destination": {
                                   "bucket": "bucket_name",
                                   "prefix": "SignedImages/"
                               }
                           }
                       },
                       "customCodeSigning": {}
                   }
               }
           ],
           "otaUpdateStatus": "CREATE_FAILED",
           "errorInfo": {
               "code": "AccessDeniedException",
               "message": "S3 object demo.bin not accessible. Please check your permissions (Service: AWSSigner; Status Code: 403; Error Code: AccessDeniedException; Request ID: 01d8e7a1-8c7c-4d85-9fd7-dcde975fdd2d)"
           }
       }
   }
   ```

   如果创建失败，则命令输出中的 `otaUpdateStatus` 字段将包含 `CREATE_FAILED`，而 `errorInfo` 字段将包含失败的详细信息。