# ResourceInitializationError: unable to pull secrets or registry auth

AWS error fixes · Updated 17 November 2026

**Short answer:** Before starting your container, ECS couldn't fetch something it needs on the task's behalf: secrets from Secrets Manager or Parameter Store, or the ECR authorisation token. The cause is almost always either no network path from the task's subnets to those services, or a task execution role missing secretsmanager:GetSecretValue, ssm:GetParameters or kms:Decrypt for the referenced secret.

## What the message looks like

```
ResourceInitializationError: unable to pull secrets or registry auth: execution resource
retrieval failed: unable to retrieve secret from asm: service call has been retried 5 time(s):
failed to fetch secret arn:aws:secretsmanager:eu-west-2:123456789012:secret:prod/db-AbCdEf
from secrets manager: … i/o timeout
```

The middle tells you which service: `asm` is Secrets Manager, `ssm` is Parameter Store, and a registry-auth variant names ECR. The ending tells you why: a timeout means networking, `AccessDeniedException` means permissions, `ResourceNotFoundException` means the reference is wrong.

## Causes and fixes

| Ending | Cause | Fix |
|---|---|---|
| `i/o timeout` / `context deadline exceeded` | Task subnets can't reach the service endpoint | NAT gateway, public IP for Fargate in public subnets, or VPC endpoints |
| `AccessDeniedException` | Execution role lacks `secretsmanager:GetSecretValue` or `ssm:GetParameters` | Grant them on the specific ARNs |
| KMS access denied | Secret encrypted with a customer managed key the execution role can't use | Grant `kms:Decrypt` on that key |
| `ResourceNotFoundException` | Wrong ARN, wrong region, or a secret that was deleted | Use the full ARN from `describe-secret` |
| Invalid JSON key or version | Bad `valueFrom` suffix for a JSON key | Use `arn…:secret:prod/db-AbCdEf:password::` |

The execution role is the one in `executionRoleArn`; the task role (`taskRoleArn`) isn't used for this step. Secrets are fetched once when the task starts, so a rotated secret only reaches the container when the task is replaced.

## Check the task definition

```
aws ecs describe-task-definition --task-definition api \
  --query 'taskDefinition.{exec: executionRoleArn, secrets: containerDefinitions[].secrets[]}'
```

Example of correct references for a whole secret, one JSON key from a secret, and a Parameter Store parameter:

```
"secrets": [
  { "name": "DB_SECRET",   "valueFrom": "arn:aws:secretsmanager:eu-west-2:123456789012:secret:prod/db-AbCdEf" },
  { "name": "DB_PASSWORD", "valueFrom": "arn:aws:secretsmanager:eu-west-2:123456789012:secret:prod/db-AbCdEf:password::" },
  { "name": "API_URL",     "valueFrom": "arn:aws:ssm:eu-west-2:123456789012:parameter/prod/api-url" }
]
```

A matching execution role policy:

```
{ "Effect": "Allow",
  "Action": ["secretsmanager:GetSecretValue", "ssm:GetParameters"],
  "Resource": ["arn:aws:secretsmanager:eu-west-2:123456789012:secret:prod/db-*",
               "arn:aws:ssm:eu-west-2:123456789012:parameter/prod/*"] }
```

## Networking for private subnets

Without NAT, the task's subnets need interface endpoints for each service the task definition uses: `secretsmanager`, `ssm`, `ecr.api`, `ecr.dkr`, `logs`, plus the `s3` gateway endpoint for image layers, and `kms` if a customer managed key is involved. Their security groups must accept HTTPS from the tasks.

Other `ResourceInitializationError` variants have the same flavour: `failed to validate logger args` usually means the `awslogs` log group doesn't exist (create it, or set `awslogs-create-group` with permission to create it), and EFS mount failures point at mount targets or security groups for NFS.

## Questions

### What is ResourceInitializationError in ECS?

ECS couldn't prepare resources a task needs before its containers start, such as secrets, the ECR auth token, the log group or EFS volumes. The task stops without running your code.

### Which IAM role needs access to secrets in ECS?

The task execution role. It needs secretsmanager:GetSecretValue or ssm:GetParameters on the referenced ARNs, and kms:Decrypt if a customer managed key encrypts them.

### How do I reference a JSON key from Secrets Manager in ECS?

Append the key to the secret ARN in valueFrom, in the form arn:…:secret:name-AbCdEf:jsonKey:: with empty version stage and version ID.

## When this happens away from your desk

This error tends to start after a networking or secrets change, and it stops every new task from launching. CloudConsole, a phone app for AWS, is built to show service events and alarms on your phone so you notice before running tasks are replaced.

[About the CloudConsole app](https://cloudconsole.dev/aws-console-app) · [Download on the App Store](https://apps.apple.com/app/cloudconsole-for-aws/id6835419710)

## Sources

- [Pass sensitive data to an Amazon ECS container](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/specifying-sensitive-data.html)
- [Amazon ECS task execution IAM role](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_execution_IAM_role.html)

## Related

- [CannotPullContainerError: pull image manifest has been retried](https://cloudconsole.dev/errors/ecs-cannotpullcontainererror)
- [KMS AccessDeniedException when reading an encrypted S3 object or secret](https://cloudconsole.dev/errors/kms-access-denied)
- [ResourceNotFoundException: Secrets Manager can't find the specified secret](https://cloudconsole.dev/errors/secretsmanager-cant-find-secret)
- [aws secretsmanager get-secret-value](https://cloudconsole.dev/cli/secretsmanager-get-secret-value)
- [aws ecs describe-task-definition](https://cloudconsole.dev/cli/ecs-describe-task-definition)
- [aws ssm get-parameter](https://cloudconsole.dev/cli/ssm-get-parameter)
- [ECS was unable to assume the role that was provided for this task](https://cloudconsole.dev/errors/ecs-unable-to-assume-role)

---

Source: https://cloudconsole.dev/errors/ecs-resourceinitializationerror

CloudConsole is an independent iPhone and Android app for Amazon Web Services by Cloudconcur Ltd. It is not affiliated with Amazon Web Services.
