

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 對 Amazon ECS ResourceInitializationError 錯誤進行疑難排解
<a name="resource-initialization-error"></a>

以下是部分 `ResourceInitialization` 錯誤訊息以及可採取的錯誤修正動作。

若要使用 檢查已停止的任務是否有錯誤訊息 AWS 管理主控台，請參閱 [檢視 Amazon ECS 已停止任務錯誤](stopped-task-errors.md)。

**Topics**
+ [

## The task cannot pull registry authentication from Amazon ECR. There is a connection issue between the task and Amazon ECR. Check your task network configuration.
](#unable-to-pull-secrets-ecr)
+ [

## The task can't download the environment variable files from Amazon S3. There is a connection issue between the task and Amazon S3. Check your task network configuration.
](#failed-to-download-env-files)
+ [

## 任務無法從 AWS Systems Manager 參數存放區提取秘密。檢查任務與 之間的網路連線 AWS Systems Manager。
](#unable-to-pull-secrets-sys-manager)
+ [

## 任務無法從中提取秘密 AWS Secrets Manager。There is a connection issue between the task and Secrets Manager. Check your task network configuration.
](#unable-to-pull-secrets-asm-no-arn)
+ [

## The task can’t pull the secret from Secrets Manager. The task can't retrieve the secret with ARN ‘*secretARN*' from Secrets Manager. Check whether the secret exists in the specified Region.
](#unable-to-pull-secrets-asm)
+ [

## pull command failed: unable to pull secrets or registry auth Check your task network configuration.
](#pull-command-failed)
+ [

## 任務找不到任務定義中所定義的 Amazon CloudWatch 日誌群組。There is a connection issue between the task and Amazon CloudWatch. Check your network configuration.
](#failed-to-initialize-logging-network)
+ [

## failed to initialize logging driver
](#failed-to-initialize-logging)
+ [

## 無法調用 EFS utils 命令來設定 EFS 磁碟區
](#efs-utils-failed)

## The task cannot pull registry authentication from Amazon ECR. There is a connection issue between the task and Amazon ECR. Check your task network configuration.
<a name="unable-to-pull-secrets-ecr"></a>

此錯誤表示任務無法連線至 Amazon ECR。

檢查任務與 Amazon ECR 之間的連線。如需相關資訊，請參閱[驗證 Amazon ECS 已停止任務的連線狀態](verify-connectivity.md)。

## The task can't download the environment variable files from Amazon S3. There is a connection issue between the task and Amazon S3. Check your task network configuration.
<a name="failed-to-download-env-files"></a>

當任務無法從 Amazon S3 下載環境檔案時，就會發生此錯誤。

檢查任務與 Amazon S3 VPC 端點之間的連線。如需相關資訊，請參閱[驗證 Amazon ECS 已停止任務的連線狀態](verify-connectivity.md)。

## 任務無法從 AWS Systems Manager 參數存放區提取秘密。檢查任務與 之間的網路連線 AWS Systems Manager。
<a name="unable-to-pull-secrets-sys-manager"></a>

當任務無法使用 Systems Manager 中的憑證提取任務定義中定義的映像時，就會發生此錯誤。

檢查任務與 Systems Manager VPC 端點之間的連線。如需相關資訊，請參閱[驗證 Amazon ECS 已停止任務的連線狀態](verify-connectivity.md)。

## 任務無法從中提取秘密 AWS Secrets Manager。There is a connection issue between the task and Secrets Manager. Check your task network configuration.
<a name="unable-to-pull-secrets-asm-no-arn"></a>

當任務無法使用 Secrets Manager 中的憑證提取任務定義中定義的映像時，就會發生此錯誤。

此錯誤表示 Systems Manager VPC 端點與任務之間存在網路連線問題。

如需有關如何驗證任務與端點之間連線的資訊，請參閱[驗證 Amazon ECS 已停止任務的連線狀態](verify-connectivity.md)。

## The task can’t pull the secret from Secrets Manager. The task can't retrieve the secret with ARN ‘*secretARN*' from Secrets Manager. Check whether the secret exists in the specified Region.
<a name="unable-to-pull-secrets-asm"></a>

當任務無法使用 Secrets Manager 中的憑證提取任務定義中定義的映像時，就會發生此錯誤。

此問題由以下其中一個原因造成：


| 錯誤原因... | 執行此作業... | 
| --- | --- | 
|   Secrets Manager VPC 端點與任務之間存在網路連線問題。 在錯誤訊息中看到下列任何字串時，表示存在網路問題： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/AmazonECS/latest/developerguide/resource-initialization-error.html)  |  驗證任務與 Secrets Manager 端點之間的連線狀態。如需詳細資訊，請參閱[驗證 Amazon ECS 已停止任務的連線狀態](verify-connectivity.md)。  | 
| 任務定義中所定義的任務執行角色，沒有 Secrets Manager 所需的許可。 |  將 Secrets Manager 所需的許可新增至任務執行角色。如需詳細資訊，請參閱[Secrets Manager 或 Systems Manager 許可](task_execution_IAM_role.md#task-execution-secrets)。  | 
| 秘密 ARN 不存在 | 檢查 Secrets Manager 中是否存在 ARN。如需有關檢視映像的資訊，請參閱 Secrets Manager Developer Guide 中的 [Find secrets in Secrets Manager](https://docs.aws.amazon.com/secretsmanager/latest/userguide/manage_search-secret.html)。 | 

## pull command failed: unable to pull secrets or registry auth Check your task network configuration.
<a name="pull-command-failed"></a>

當任務無法連線至 Amazon ECR、Systems Manager 或 Secrets Manager 時，就會發生此錯誤。此問題源自於網路組態錯誤。

若要修正此問題，請驗證任務與 Amazon ECR 之間的連線狀態。您也需要檢查任務與儲存秘密的服務 (Systems Manager 或 Secrets Manager) 之間的連線狀態。如需詳細資訊，請參閱[驗證 Amazon ECS 已停止任務的連線狀態](verify-connectivity.md)。

## 任務找不到任務定義中所定義的 Amazon CloudWatch 日誌群組。There is a connection issue between the task and Amazon CloudWatch. Check your network configuration.
<a name="failed-to-initialize-logging-network"></a>

當任務找不到您在任務定義中定義的 CloudWatch 日誌群組時，就會發生此錯誤。

此錯誤表示 CloudWatch VPC 端點與任務之間存在網路連線問題。

如需有關如何驗證任務與端點之間連線的資訊，請參閱[驗證 Amazon ECS 已停止任務的連線狀態](verify-connectivity.md)。

## failed to initialize logging driver
<a name="failed-to-initialize-logging"></a>

當任務找不到您在任務定義中定義的 CloudWatch 日誌群組時，就會發生此錯誤。

此錯誤表示任務定義中的 CloudWatch 群組不存在。

使用下列步驟尋找缺少的 CloudWatch。

1. 執行下列命令來取得任務定義資訊。

   ```
   aws ecs describe-task-definition \ 
       --task-definition task-def-name
   ```

   查看每個容器的輸出，並記下 `awslogs-group` 值。

   ```
   "logConfiguration": {
                   "logDriver": "awslogs",
                   "options": {
                       "awslogs-group": "/ecs/example-group",
                       "awslogs-create-group": "true",
                       "awslogs-region": "us-east-1",
                       "awslogs-stream-prefix": "ecs"
                   },
   ```

1. 確認群組存在於 CloudWatch 中。如需詳細資訊，請參閱 *Amazon CloudWatch Logs User Guide* 中的 [Working with log groups and log streams](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/Working-with-log-groups-and-streams.html)。

   問題可能是任務定義中指定的群組不正確，也可能是日誌群組不存在。

1. 修正問題。    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/AmazonECS/latest/developerguide/resource-initialization-error.html)

## 無法調用 EFS utils 命令來設定 EFS 磁碟區
<a name="efs-utils-failed"></a>

下列問題可能會阻止您在任務上掛載 Amazon EFS 磁碟區：
+ Amazon EFS 檔案系統設定不正確。
+ 任務缺少必要許可。
+ 存在與網路與 VPC 組態相關的問題。

 如需有關如何偵錯和修正此問題的資訊，請參閱[為何我無法在 re：Post 上的 AWS Fargate 任務上掛載 Amazon EFS 磁碟區](https://repost.aws/knowledge-center/fargate-unable-to-mount-efs)。 AWS 