ECS Fargate ResourceInitializationError: One Checklist
If Amazon ECS Fargate stops with ResourceInitializationError: unable to pull secrets or registry auth, inspect what the task must retrieve before your container starts: its image and registry credentials, Secrets Manager secrets, and Systems Manager Parameter Store values. The usual causes are unavailable network paths, an incorrect task execution role, or a wrong secret ARN. The surprising part is that a public subnet alone does not give a Fargate task internet access: it also needs a public IP and an internet-gateway route. Fix the network path that matches your task, then fix the precise IAM permission instead of changing your application code.
Jake runs a neighborhood phone-repair shop and his appointment API runs in a Fargate task. He has reserved a fictional $50 for a weekend promotion, but a fresh deployment leaves its replacement task stopped before the app serves one request. The image exists in ECR and the database password exists in Secrets Manager. Those facts tell him nothing about whether the task can reach either service or whether its startup identity can read the secret.
The launch fails before any application log appears, which makes debugging inside the container tempting but ineffective. The practical place to investigate is the task configuration and its startup dependencies. Once the missing network route or permission is fixed, a new task attempt can start with the same unchanged image.
Understand the three startup fetches before touching your code
When you see a task stop immediately, distinguish initialization from application execution. Fargate needs to make certain external calls to prepare the container, and those calls can fail before your entrypoint runs. Your application gets no chance to print its usual startup banner if the initialization phase fails. That is why changing a Python handler or Node.js startup script rarely fixes this specific error.
The first dependency is the container image and its registry authentication. For a private Amazon ECR image, Fargate obtains authorization and retrieves the image manifest and layers, including layers stored in Amazon S3. An image in a private non-ECR registry can instead require credentials referenced in the task definition through repositoryCredentials. Treat the image location, registry permissions, and route to the registry as distinct checks.
The second dependency is a secret from AWS Secrets Manager when your task definition injects values or specifies private-registry credentials. The third is a parameter from Systems Manager Parameter Store when the container definition injects a parameter as an environment variable. These values are fetched using task initialization capabilities and its execution-role permissions, not your running application code. A separate S3 environment file and the CloudWatch Logs driver can add further startup dependencies.
Not every task fetches all three items. A task using public images and no secret injection will have a much shorter startup path than one using private ECR images, multiple encrypted secrets, and the awslogs driver. Start by reading the actual task definition and the detailed failure string, then investigate only the services it uses. This spares you network infrastructure purchases and wider IAM permissions for dependencies that were not even configured.
Jake: "My app printed no log at all. Does that mean the container crashed instantly?"
Ethan: "Not necessarily. Fargate may still be fetching the image or configuration. If that fetch fails, your application is not started at all."
Read the full ResourceInitializationError before choosing a fix
The top line is intentionally broad, so keep reading past ResourceInitializationError. Expand the task stop reason in the ECS console or inspect the task through the API. Look for the service name, an ARN, a URL, and words such as AccessDenied, i/o timeout, or ResourceNotFoundException. Those details tell you which connection or authorization check actually failed.
A timeout mentioning api.ecr suggests a route to the ECR API is unavailable. A timeout referring to Secrets Manager or SSM suggests a different endpoint or NAT failure. An explicit access-denied response can mean the endpoint is reachable but a role policy, KMS policy, endpoint policy, or resource policy prevents the request. A missing ARN means connectivity changes are unlikely to create the missing secret.
Some errors use older wording such as execution resource retrieval failed or service call has been retried. Newer stop reasons may include a friendlier description followed by the underlying network or service response. Search within the full message for the first concrete service and operation rather than relying on one rigid string match. ECS uses related messages for S3 environment-file failures and CloudWatch Logs initialization too.
Your quickest practical evidence is the task ARN, stopping reason, stopped reason, and the task definition revision used by that particular attempt. A newer task definition may already contain a fix while an older failed task still displays the previous error. Confirm which revision failed before comparing it to what you see in the editor now. Keep timestamps and the AWS Region with the error so that later account or Region comparisons are meaningful.
| Error clue | Most useful first check | Usually not the first fix |
|---|---|---|
api.ecr... i/o timeout | Subnet route, ECR API endpoint, endpoint SG | Change application image code |
secret... AccessDenied | Execution role, secret and KMS policies | Add a public IP without checking authorization |
ssm... context deadline exceeded | SSM path through NAT or SSM endpoint | Grant unrelated ECR permissions |
ResourceNotFoundException | Exact secret ARN and Region | Create more VPC endpoints |
failed to initialize logging driver | Log group, logs endpoint, IAM | Change container HTTP listener |
failed to download env files | S3 object, route and S3 permission | Add Secrets Manager permissions |
Get the stopped task details in the console and CLI
In the ECS console, open your cluster and select the Tasks tab, then show stopped tasks. Choose the failed task and read the stopped reason and container-level details. If you use an ECS service, also inspect its Events area to see whether multiple replacement tasks fail in the same way. A repeating pattern across fresh tasks points to a shared network or role configuration rather than a one-off application crash.
The CLI can retrieve the same information when the console truncates a long message. Start with the correct AWS profile and Region because ECS tasks are Region-scoped. For a task created by a service, the cluster, service, task definition, and network configuration should all be reviewed together. Your local CLI may be using a different account from the one selected in the web console.
aws sts get-caller-identity
aws ecs list-tasks \
--cluster my-cluster \
--desired-status STOPPED \
--region us-east-1
aws ecs describe-tasks \
--cluster my-cluster \
--tasks YOUR_STOPPED_TASK_ARN \
--region us-east-1 \
--query "tasks[].{StoppedReason:stoppedReason,TaskDefinition:taskDefinitionArn,Containers:containers[].reason,Attachments:attachments}"
The list of stopped tasks is not an unlimited historical archive, so investigate promptly after the failure. Replace the sample cluster and ARN with real values. The returned task definition ARN identifies which image, execution role, secret references, and log settings the task actually attempted to use. Read that definition before you edit IAM, especially when deployment automation creates new revisions.
aws ecs describe-task-definition \
--task-definition MY_TASK_DEFINITION_REVISION \
--region us-east-1 \
--query "taskDefinition.{ExecutionRole:executionRoleArn,TaskRole:taskRoleArn,Containers:containerDefinitions}"
The stopped-task message will rarely include every relevant network detail. Retrieve your ECS service networking and inspect the subnet IDs, security group IDs, and assignPublicIp setting. Map those subnets to their route tables in VPC. When there are several subnets, check each one; a service can succeed in one Availability Zone and fail in another if its routes or endpoints differ.
Fix the execution role rather than automatically changing the task role
Two IAM role fields sit near each other in an ECS task definition, and mixing them up is a common dead end. executionRoleArn gives the ECS/Fargate startup machinery permission to perform operations such as pulling ECR images, fetching injected secrets, and writing configured logs. taskRoleArn provides credentials for application code once your container is running. A pre-start secret-fetch failure normally implicates the execution role.
The AWS-managed policy AmazonECSTaskExecutionRolePolicy is a useful baseline for private ECR image retrieval and CloudWatch Logs operations. It does not mean every Secrets Manager secret or Parameter Store parameter in your application is automatically readable. Those resources need additional policies on the execution role when they are injected through the task definition. Restrict those grants to the resources this task actually needs.
By contrast, an application using an SDK to call Secrets Manager after startup normally requires the task role to have the relevant permission. That is a different retrieval phase: the application code is issuing the API call rather than ECS injecting a value before launch. It can produce different error messages and potentially leave application logs. Decide which role to edit by locating where the secret is referenced and when the request is made.
Both roles must be appropriately trusted and selectable, and a separate deployment identity needs permissions to register task definitions and pass roles where required. A deployment-time iam:PassRole denial is not the same error as Fargate lacking secretsmanager:GetSecretValue. Keep the caller, execution role, and application task role separate while diagnosing. Overly broad policies on the wrong principal merely obscure the real cause.
| Identity | Used by | Typical responsibility |
|---|---|---|
| Task execution role | ECS/Fargate startup | ECR authorization, injected secrets/parameters, configured logs |
| Task role | Your running container | SDK requests to DynamoDB, S3, Secrets Manager, and other services |
| Deployment principal | CLI, CI or CloudFormation | Create/update ECS resources and pass approved IAM roles |
Jake: "I attached Secrets Manager access to the task role. Why did startup still fail?"
Ethan: "That role is for code running inside the container. The execution role needs access when ECS is injecting the secret before startup."
Grant Secrets Manager permissions using the actual secret ARN
If your container definition uses secrets or its registry configuration references Secrets Manager, Fargate needs a route to the Secrets Manager API and permission to read that exact secret. The required action for an injected Secrets Manager secret is secretsmanager:GetSecretValue. The secret ARN includes its Region, account, name, and a generated suffix. Use the exact ARN rather than guessing what the suffix might be.
For a secret named shop/db-password, an ARN can resemble arn:aws:secretsmanager:us-east-1:111122223333:secret:shop/db-password-AbCdEf. This example is illustrative, not an existing customer secret. If your deployment names a JSON key inside a secret, the underlying resource is still the Secrets Manager secret with its own ARN. Match your policy resource to that resource and ensure the task definition selects a valid key or version.
Attach an IAM permission statement to the task execution role, not as a replacement for its trust policy. If encryption uses a customer-managed KMS key, you may also need kms:Decrypt permission and an appropriate KMS key policy. Permission in IAM alone does not override an explicit denial in a resource policy, endpoint policy, or key policy. Treat every access-denied response as a combination of identity, resource, and applicable guardrails.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "secretsmanager:GetSecretValue",
"Resource": "arn:aws:secretsmanager:us-east-1:111122223333:secret:shop/db-password-AbCdEf"
},
{
"Effect": "Allow",
"Action": "kms:Decrypt",
"Resource": "arn:aws:kms:us-east-1:111122223333:key/EXAMPLE-KEY-ID"
}
]
}
The KMS statement above is only necessary for an applicable customer-managed key and must use the real key ARN. When the secret uses AWS-managed encryption, that custom-key statement is generally unnecessary. To check the secret identity without printing its value, use aws secretsmanager describe-secret --secret-id .... Keep plaintext secrets out of CI logs, even when you are only testing connectivity.
Grant Parameter Store permissions without confusing parameter names and ARNs
If an ECS task definition references a Systems Manager Parameter Store value in its secrets list, the execution role needs ssm:GetParameters. This plural API action matters because policies written for application SDK calls sometimes list only ssm:GetParameter. The ECS injection case is specifically documented with the plural action. Check the role permission rather than granting every Systems Manager action.
A parameter path like /shop/prod/api-key has an ARN of the form arn:aws:ssm:us-east-1:111122223333:parameter/shop/prod/api-key. The ARN contains parameter/ followed by the hierarchy, so the display name begins with a slash while the ARN does not double that slash. Wildcarding every parameter in the account can conceal a typo while granting unnecessary access. Match the actual path and Region supplied to the task.
If the parameter is a SecureString protected with a customer-managed KMS key, include the relevant decrypt permission and confirm the key policy. Some advanced Parameter Store patterns reference Secrets Manager values, in which case the corresponding Secrets Manager permission also matters. A missing parameter and an encrypted parameter that cannot be decrypted require different corrections. Read the complete ECS message rather than assuming every SSM failure is network-related.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "ssm:GetParameters",
"Resource": "arn:aws:ssm:us-east-1:111122223333:parameter/shop/prod/api-key"
},
{
"Effect": "Allow",
"Action": "kms:Decrypt",
"Resource": "arn:aws:kms:us-east-1:111122223333:key/EXAMPLE-KEY-ID"
}
]
}
Use aws ssm describe-parameters or aws ssm get-parameter with suitable permissions to confirm that a parameter exists and has the expected Region and path. For diagnostics, describe the metadata or use a non-sensitive parameter rather than printing decrypted values. Cross-Region references have additional ARN requirements, and VPC endpoints are Region-specific. When the secret lives elsewhere, plan the explicit cross-Region connectivity and IAM path instead of assuming a local endpoint reaches it.
Take a breath before you open the VPC console, because this is the decision that decides your bill. You pick your path by subnet type, not by habit. Once you know whether your task has an internet route, every endpoint question below answers itself for you.
Choose networking by subnet type and outbound path
The most frequent infrastructure decision is whether a Fargate task gets internet egress through a public IP, a NAT gateway, or interface and gateway VPC endpoints. These are alternatives for some AWS service calls, but they are not interchangeable configurations. A task in a public subnet does not automatically receive a public IP. A task in a private subnet with no NAT and no necessary endpoints has no route to those remote service APIs.
A public subnet is one whose route table leads to an internet gateway; it does not mean every task interface is publicly addressable. For Fargate outbound internet access through that route, the task must be assigned a public IP. A private subnet typically points its default IPv4 route to a NAT gateway in a public subnet, with the NAT gateway itself routed to the internet gateway. Private-only designs instead use PrivateLink interface endpoints and S3 gateway endpoints where supported.
| Task subnet arrangement | Internet path available? | Practical startup plan |
|---|---|---|
| Public subnet + public IP + IGW route | Yes, subject to SG/NACL/DNS | Private ECR and service APIs reachable through public endpoints |
| Public subnet, public IP disabled | Not through IGW as an ordinary outbound path | Assign public IP or provide NAT/endpoints |
| Private subnet + valid NAT route | Yes, via NAT | Use service public endpoints; confirm NAT connectivity |
| Private subnet + no NAT + relevant VPC endpoints | AWS service paths only | ECR API/DKR + S3 and conditional Secrets/SSM/Logs endpoints |
| Private subnet + neither NAT nor endpoints | No suitable egress | Change subnet egress design before retrying |
Inspect the actual route table associated with each task subnet, not the VPC main route table by assumption. Check DNS resolution and network ACLs alongside security groups. A configured NAT gateway can still be ineffective if the task subnet has the wrong route or the NAT gateway lacks its own internet-facing path. Likewise, an interface endpoint may exist but not be reachable from the task’s security group.
The simplest design for a short-lived demonstration may use a public subnet with an assigned public IP and restrictive security groups. Production tasks often use private subnets with NAT or endpoints so containers are not directly internet-addressable. Choose based on your security and operational requirements, not just which console toggle makes the first error disappear. Review network costs separately using current Region pricing; this troubleshooting guide does not assume a fixed NAT or endpoint price.
Jake: "Our task is in a public subnet, so it must have internet, right?"
Ethan: "The subnet has a route to the internet gateway. The Fargate task also needs its own public IP to use that path directly."
Create the ECR endpoints and S3 gateway route as a set
For a private ECR pull without NAT or public internet access, your endpoint set must support both authorization and image-layer retrieval. On Fargate Linux platform version 1.4.0 and later, the documented ECR interface endpoints are com.amazonaws.REGION.ecr.api and com.amazonaws.REGION.ecr.dkr. You also need an S3 gateway endpoint because private ECR image layers are stored in Amazon S3. An ECR interface endpoint alone is not sufficient for the full pull.
Use the VPC console under Endpoints to create the two interface endpoints in the task VPC. Enable private DNS for the service endpoints, and select appropriate subnets and security groups. Add a gateway endpoint for com.amazonaws.REGION.s3 and associate it with the route tables used by your task subnets. A gateway endpoint is not configured like a security-group-protected interface endpoint; its route-table association is essential.
A Fargate task on an older Linux platform version can have different ECR API networking behavior, so the 1.4.0+ endpoint requirement should not be applied blindly to legacy deployments. For current modern platform versions, use the full set. The ECR documentation also describes special considerations for pull-through cache first pulls and certain foreign image layers; those can require an internet path even when ordinary private ECR pulls work through endpoints. Your task image source determines whether these exceptions matter.
An endpoint policy is another authorization layer. If you restrict the ECR endpoint or S3 gateway endpoint, ensure it permits the required operations and ECR-backed S3 layer bucket access. Keeping only your application S3 bucket in an endpoint policy can accidentally block retrieval of the ECR layer bucket. Check the real Region in the automatically managed ECR layer bucket pattern rather than hardcoding an unrelated Region. Preserve minimum necessary access without blocking the registry workflow.
com.amazonaws.us-east-1.ecr.api # Interface endpoint
com.amazonaws.us-east-1.ecr.dkr # Interface endpoint
com.amazonaws.us-east-1.s3 # Gateway endpoint
Add Secrets Manager, SSM, and CloudWatch Logs endpoints only when needed
If your task injects a Secrets Manager secret and has no NAT/public egress, it needs an interface VPC endpoint for com.amazonaws.REGION.secretsmanager. The endpoint must be in a network position reachable from the task and permit HTTPS traffic through its security group. Private DNS allows standard regional service names to resolve to reachable private endpoint addresses. Without a route or working DNS, adding IAM permission alone will not help.
For injected Systems Manager Parameter Store values, create com.amazonaws.REGION.ssm when operating without internet egress. This is the endpoint for the Systems Manager API used to fetch parameter values. The ssmmessages and ec2messages endpoints seen in Systems Manager agent tutorials serve different management communications and should not automatically be assumed necessary for a simple Parameter Store injection. Add endpoints according to actual features rather than every service name that begins with SSM.
When using the ECS awslogs log driver in private-only networking, create com.amazonaws.REGION.logs so the task can reach CloudWatch Logs. If a log group is missing or the execution role cannot write to it, those are separate configuration errors. An endpoint cannot create a log group on your behalf without adequate IAM authorization or an appropriate configuration. Check the log group name, the Region, and any settings that request automatic log-group creation.
A customer-managed KMS key used for Secrets Manager or Parameter Store can require decrypt permission, but this does not automatically mean the task must have a dedicated KMS endpoint for the described startup fetch. The retrieving service handles its own service-side encryption interactions in supported flows. Add a KMS endpoint when the task or another workload actually calls KMS over the VPC network. Distinguishing IAM authorization from network destinations helps keep the endpoint plan accurate.
| Endpoint service | Type | Needed without NAT/public egress when |
|---|---|---|
ecr.api + ecr.dkr | Two interfaces | Pulling private ECR images on modern Fargate |
s3 | Gateway | Retrieving ECR image layers (also env files as configured) |
secretsmanager | Interface | Injecting Secrets Manager values or private registry credentials |
ssm | Interface | Injecting Parameter Store values |
logs | Interface | Using CloudWatch Logs awslogs driver |
kms | Interface, conditional | Task directly makes KMS API requests |
Make the task and endpoint security groups agree on HTTPS
You can create every correct endpoint and still receive a timeout if security groups block the connection. Interface endpoint network interfaces need inbound TCP 443 from the task’s source security group or an appropriately scoped source CIDR. The task security group must permit outbound TCP 443 to the endpoint destination. Security groups are stateful, so permitted connection responses need no matching ephemeral-port rule in the opposite direction.
The task does not normally need inbound HTTPS simply to fetch an image or injected secret. Its inbound rules are driven by application traffic and load balancers, which occur after startup. For diagnosis, focus on task egress and endpoint ingress rather than opening port 443 inbound on every task. Keeping rules scoped by security-group references can be simpler and safer than wide CIDR ranges in a VPC with multiple subnets.
Network ACLs are stateless, so they can block return traffic even when security groups are correct. Check the task subnet and endpoint subnet ACLs for the necessary outbound HTTPS and return ephemeral port flows. Also confirm VPC DNS support, endpoint private DNS, and any custom DNS forwarding behavior. A failure to resolve the private endpoint correctly can make a healthy endpoint appear unreachable.
If the service uses multiple subnets or Availability Zones, repeat the route and endpoint reachability check for each. The interface endpoint is represented by private network interfaces in the selected subnets, and the correct security group must be attached to those endpoints. A task that alternates between successful and failed deployments often warrants a subnet-by-subnet comparison. A working task in one subnet is no proof that all network paths are healthy.
Jake: "Should I open port 443 inbound on the task security group?"
Ethan: "For fetching AWS services, the task initiates outbound HTTPS. The endpoint needs inbound 443 from the task; your task does not need a public inbound rule for this fetch."
Follow this network repair sequence in the VPC console
If your failed task is using public networking, select the subnet in the VPC console and inspect its associated route table. Verify a default IPv4 route to the internet gateway and a public-IP assignment on the task. Check that the task security group allows the needed egress and that DNS resolves the ECR, Secrets Manager, or SSM hostname. A default route on some other subnet does not help this task.
For a private subnet that uses NAT, inspect the task subnet route to the NAT gateway. Then inspect the NAT gateway placement and upstream public-subnet route to the internet gateway. Review network ACLs and any firewall in the path if the basic routes appear correct. A NAT gateway can be available as a resource while the necessary route remains absent from the task subnet.
For private-only endpoints, list all needed endpoint services first and create the endpoints in the same Region and VPC as your task. Attach appropriate interface endpoint security groups, enable private DNS where required, and associate the S3 gateway endpoint with every task subnet route table. Then review endpoint policies and any organization restrictions that may deny the underlying API calls. Test the whole path rather than declaring success as soon as the endpoint appears in the VPC console.
ECS service deployments can create replacement tasks while you change networking. To make testing controlled, record the current service network configuration and task definition revision. After changes, request a new deployment so fresh tasks exercise the updated paths; changing a stopped task does not restart that same task. Compare the new attempt’s stopped reason and timestamps with the original before concluding whether the change addressed the correct dependency.
- Read the stopped task error and identify the exact service.
- Record the task subnet IDs, security groups, and public-IP setting.
- Review every task subnet route table.
- Choose public-IP plus IGW, NAT, or a complete endpoint plan.
- Check endpoint private DNS and security groups for TCP 443.
- Review endpoint policies and execution-role permissions.
- Start a replacement task and compare the new error or success state.
Inspect task-definition image, secret, and log references
Your task definition ties together otherwise separate resources. The image field identifies the registry account, Region, repository, and tag or digest. The secrets entries identify Secrets Manager or Parameter Store resources. The logConfiguration controls whether CloudWatch Logs becomes another required startup network path. Reading these entries together reveals the dependency chain without guessing from the cluster name.
A typical private ECR image has a registry hostname such as 111122223333.dkr.ecr.us-east-1.amazonaws.com. The task execution role must be able to retrieve its registry authorization and pull the image from the target repository. An image in another AWS account can require repository policy permissions in addition to the execution role permissions. Check that the repository and image tag really exist before attributing every failure to NAT or PrivateLink.
Secrets injected by a task definition are commonly mapped to environment variable names, but the source value should remain an ARN or supported resource name rather than a plaintext password. Rotation of a referenced secret does not instantly mutate the environment variables of running tasks. A new deployment or new tasks are needed to pick up the injected value. That is a lifecycle concern once initialization succeeds, not a reason to echo secret data into logs.
The following abbreviated JSON shows how a task definition can reference an ECR image, Secrets Manager, and Parameter Store without storing passwords directly in the definition. It is a structural illustration; you still need valid CPU and memory values, platform settings, resources, and account-specific role ARNs in a complete registration. Always replace example names and ARNs with actual values and verify the supported field formats for your deployment.
{
"family": "shop-api",
"networkMode": "awsvpc",
"requiresCompatibilities": ["FARGATE"],
"cpu": "256",
"memory": "512",
"executionRoleArn": "arn:aws:iam::111122223333:role/ecsTaskExecutionRole",
"taskRoleArn": "arn:aws:iam::111122223333:role/shopAppTaskRole",
"containerDefinitions": [
{
"name": "shop-api",
"image": "111122223333.dkr.ecr.us-east-1.amazonaws.com/shop-api:latest",
"essential": true,
"secrets": [
{
"name": "DB_PASSWORD",
"valueFrom": "arn:aws:secretsmanager:us-east-1:111122223333:secret:shop/db-password-AbCdEf"
},
{
"name": "API_KEY",
"valueFrom": "arn:aws:ssm:us-east-1:111122223333:parameter/shop/prod/api-key"
}
],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/shop-api",
"awslogs-region": "us-east-1",
"awslogs-stream-prefix": "ecs"
}
}
}
]
}
Do not overlook CloudWatch Logs and S3 environment files
A task may retrieve its ECR credentials and injected secrets successfully and then fail on another initialization dependency. When the awslogs driver is configured, Fargate needs to reach CloudWatch Logs and use an existing log group or an authorized creation path. A failed to initialize logging driver error is a prompt to inspect log configuration, execution-role logging permissions, and networking to the Logs API. Fixing Secrets Manager alone does not address that separate dependency.
Environment variable files are another separate feature: an ECS task definition can reference an object in Amazon S3 containing environment variables. When that object cannot be downloaded, the error may say failed to download env files. Check the object ARN, execution-role permissions, bucket restrictions, and the S3 network path. In a private endpoint design, confirm the S3 gateway endpoint and its route-table association.
The S3 access involved in ECR image-layer retrieval is not the same as an application accessing its business data bucket. ECR relies on a service-managed regional S3 layer bucket, and overly narrow S3 endpoint policies can block layer downloads. The application may separately require task-role S3 permissions after it starts. Keep the ECR image pull, ECS environment-file retrieval, and application S3 access distinct during troubleshooting.
CloudWatch log group creation is also a configuration choice. A task that expects an existing group can fail when the group name or Region is wrong, even if its network and roles are otherwise correct. The fastest check is to open CloudWatch Logs in the task Region and verify the group exactly matches the task definition. If you allow automatic creation, ensure the required permission and configuration are present rather than assuming that behavior happens by default.
Separate network timeouts from AccessDenied and missing resources
A timeout generally means the task did not receive a usable response from the service endpoint in time. Investigate routes, endpoint selection, security groups, NACLs, DNS, and service reachability. An explicit AccessDeniedException indicates that a request reached an authorization decision somewhere, so repeatedly adding NAT gateways is unlikely to be the correct first action. Read the denied action and resource before editing policies.
For Secrets Manager, a missing secretsmanager:GetSecretValue action on the execution role is a straightforward permission issue. If the action is allowed but you still receive denial, inspect the secret resource policy, customer-managed KMS key access, session restrictions, service control policies, and endpoint policy where applicable. A private endpoint with a restrictive policy can reject a call that an identity policy otherwise permits. Capture the actual secret ARN and caller role during the investigation.
For Parameter Store, the required ssm:GetParameters permission must cover the actual parameter ARN. SecureString values using a customer-managed key can additionally require kms:Decrypt. For ECR, ensure the execution role includes the actions required by private registry image pulls and that any cross-account repository policy permits the pull. Permissions that apply to your laptop AWS user are not carried over to Fargate.
A missing resource generates a different branch. An ARN from the wrong Region, a deleted secret, or a typo in the container definition can lead to ResourceNotFoundException. Check existence without disclosing secret values, then correct the task definition or restore the required resource through your usual change process. A newly created VPC endpoint cannot retrieve a secret that does not exist.
Use the AWS troubleshooting automation to narrow the failure
When manual checks keep going in circles, AWS provides the AWSSupport-TroubleshootECSTaskFailedToStart Systems Manager Automation runbook. It examines common reasons a task failed to start, including registry connectivity, execution-role permissions, endpoint reachability, security group rules, secret references, and logging settings. Run it in the same Region as the failed task. It is a diagnostic aid, not a substitute for reviewing the actual IAM and network changes you apply afterward.
The runbook can use temporary resources to probe networking, including a Lambda function and associated role when connectivity tests are required. Those resources are created in your account for the analysis and removed by the automation when no longer needed. Review permissions and organizational controls before invoking automated diagnostics in production. A security team may need to approve the automation’s ability to inspect VPC and IAM configuration.
Open Systems Manager, navigate to Automation, select the runbook, and provide the requested inputs for your failed ECS task. Inspect the steps and output to identify which dependency is unreachable or unauthorized. Compare results to the stopped reason rather than applying every possible suggested change. A network test that passes for one endpoint does not prove an unrelated secret or S3 layer route is healthy.
For a persistent incident, preserve the runbook execution identifier and results alongside the ECS task ARN and task definition revision. This makes escalation far more useful than reporting only that the service is stuck. You should still verify fixes by starting a replacement task and observing that it becomes healthy, not by claiming success when an IAM policy saves or an endpoint reaches Available state. End-to-end task startup is the outcome that matters.
You have the checklist; now watch it run against a real two-subnet failure, the kind you hit when one task starts and its replacement does not. Follow along with your own cluster open, because you will recognize your own symptoms in the first two steps.
Work through a two-subnet private Fargate failure
Imagine a service with tasks spread across two private subnets in the same Region. One subnet already has a NAT route, while the other has no NAT route and no interface endpoints. The service scheduler can place tasks in either subnet, so some task attempts start and others stop with an ECR API timeout. This scenario explains why a single successful run does not prove the overall deployment configuration is sound.
Suppose each task needs one private ECR image, one Secrets Manager password, one SSM parameter, and CloudWatch Logs. A private-only endpoint solution includes two ECR interface endpoints, one S3 gateway endpoint, and three conditional interface endpoints for Secrets Manager, SSM, and Logs. That is five interface endpoint service names plus one gateway service in this illustrative set. Endpoint service count is not the same as the number of endpoint network interfaces across Availability Zones.
The immediate task is to make both subnet paths consistent. If you choose NAT, correct the private subnet routes to working NAT gateways and confirm upstream internet access. If you choose endpoints, associate the S3 gateway endpoint with both relevant route tables, arrange accessible interface endpoints, and permit HTTPS from both task subnet security groups. Then confirm all IAM resource permissions match the actual secrets and parameter.
The next deployment should be evaluated in both subnets. If the error changes from i/o timeout to AccessDenied, that is not the same failure repeating: connectivity may now be available and an authorization rule is being evaluated. Use the new message to isolate the remaining issue. Count infrastructure resources as a successful application deployment only once the running task passes its health check.
For a timing illustration, assume a service tries one replacement task at 09:00 and another at 09:05. A route fix applied at 09:03 cannot retroactively repair the already stopped 09:00 task; the later attempt exercises the new configuration. Those are example times, not ECS scheduling guarantees. The point is to compare new attempts after changes rather than waiting for a failed task to revive.
Jake: "The next attempt changed from timeout to AccessDenied. Did my route fix fail?"
Ethan: "The new response is useful: the request may now reach the service. Check the exact denied action or resource instead of undoing the network fix."
Avoid an expensive network workaround you do not need
NAT gateways, interface endpoints, and data transfer can create ongoing charges, and the best design depends on workload volume and Region. A public-IP path may spare you an always-on NAT gateway for a short demonstration, but it exposes a different network posture and requires appropriate controls. A private endpoint plan can be attractive for predictable AWS-service traffic, yet each interface endpoint may incur hourly and data processing charges. There is no responsible one-price answer for every VPC topology.
Before adding every conceivable endpoint, inventory the task startup dependencies. A task that uses no Secrets Manager values does not need a Secrets Manager endpoint solely to cure an ECR image-pull error. A task that logs elsewhere may not need the CloudWatch Logs endpoint. An application that calls a public third-party API still needs a suitable internet egress path, because private AWS endpoints reach AWS services only, not the general internet.
Network cost is only one part of the decision. NAT provides flexible outbound access, while private endpoints can help keep certain AWS service calls on private network paths and support stricter endpoint policies. Public-IP tasks can be operationally simple but require careful thought about network exposure. Choose the smallest architecture that satisfies your actual service dependencies, security expectations, and availability requirements.
For a repeatable calculation, identify the number of interface endpoints in each Availability Zone, expected running hours, projected traffic through them, NAT gateway hours if used, and regional data-transfer conditions. Multiply by current published prices in the target Region rather than reusing a quote from another account or year. A quota, product name, or topology diagram without Region-specific prices is not a bill. Pricing should be reviewed independently before production rollout.
Collect a complete incident package when startup still fails
If the task remains stopped after route and permission corrections, collect the exact new stopped reason rather than assuming the original one persists. Save the task ARN, task-definition revision, account, Region, timestamps, subnet IDs, security groups, and endpoint IDs. Record the actual executionRoleArn and the secret and parameter ARNs. Redact values but not resource identifiers needed to diagnose reachability or authorization.
For a network case, capture the task subnet route tables, VPC DNS settings, private DNS configurations, endpoint security group ingress, task security group egress, and any relevant NACL or firewall policies. If an interface endpoint has an endpoint policy, include a sanitized copy. For a secret case, record the denied action and resource, resource policy, KMS key type, and parameter path. This evidence keeps the support conversation focused on the failed API call.
A deployment pipeline may have its own errors that occur before ECS starts a task, including IAM PassRole denials or invalid task-definition registration. Those belong to a different workflow than Fargate initialization. If your failed task is no longer available for inspection, reproduce through a controlled replacement task and record the new task ARN immediately. Change IAM or VPC architecture, not both at once, unless the evidence clearly calls for both.
If you use AWS Support, supply the stopped reason and the relevant diagnostic runbook output. Support can investigate service-side behavior and help identify an account-specific restriction, but it cannot turn a nonexistent secret into a valid resource or override organizational permission policies without authorization. Keep a documented rollback path for route and security-group changes. Your objective is a task that reaches healthy RUNNING state with the same security expectations you started with.
Frequently asked questions about ECS Fargate ResourceInitializationError
What causes ResourceInitializationError in ECS Fargate?
A Fargate task could not prepare a dependency before its container started, such as image authorization, an injected secret, a parameter, a log driver, or an S3 environment file. Read the detailed stopped reason to identify the failing service. Check its network path, execution-role permission, and referenced resource.
How do I fix ResourceInitializationError unable to pull secrets?
Identify whether the task fetches a Secrets Manager secret or an SSM parameter, then check the reference and the task execution role. With private-only networking, configure the matching regional interface endpoint and allow HTTPS between the task and endpoint. If the error contains AccessDenied or ResourceNotFoundException, fix authorization or the resource reference.
What does unable to pull secrets or registry auth mean in Fargate?
It means Fargate failed to obtain startup authentication or configuration needed to prepare a container. ECR connectivity, Secrets Manager connectivity, or Systems Manager connectivity may be involved. The detailed nested error reveals which dependency failed.
Which role needs Secrets Manager access for ECS environment variables?
The task execution role needs secretsmanager:GetSecretValue when ECS injects a Secrets Manager value through the task definition. The task role is generally used when application code fetches the secret after startup. Make sure the permission resource covers the exact secret ARN.
What permission does ECS need to read SSM Parameter Store values?
For parameters injected through the ECS task definition, grant ssm:GetParameters to the task execution role for the matching parameter ARN. A SecureString protected by a customer-managed KMS key can additionally require kms:Decrypt. Check the endpoint or NAT path separately from IAM.
Does Fargate need a public IP to pull from ECR?
Not always. A task using direct internet gateway egress through a public subnet needs a public IP, appropriate routes, and security group rules. Private-subnet tasks can use NAT or suitable ECR and S3 VPC endpoints instead.
Can Fargate pull ECR images without a NAT gateway?
Yes. For modern Fargate Linux platform versions, private ECR pulls can use the ecr.api and ecr.dkr interface endpoints plus an S3 gateway endpoint. Configure endpoint networking, private DNS, permissions, and the S3 route-table association. Other startup dependencies may require additional endpoints.
Which Fargate VPC endpoints are required for ECR?
Fargate Linux platform 1.4.0 or later requires ecr.api, ecr.dkr, and an S3 gateway endpoint for private ECR pulls through VPC endpoints. The S3 endpoint supports image-layer downloads. Add conditional endpoints for Secrets Manager, SSM, and CloudWatch Logs as used.
Do ECS Fargate tasks need ECS interface VPC endpoints?
Fargate tasks ordinarily reach the ECS control plane without ECS interface endpoints. They may need ECR, Secrets Manager, SSM, CloudWatch Logs, and S3 endpoints for startup resources in a private-only VPC. Choose endpoints based on the task feature set.
Which security group rule fixes a Fargate endpoint timeout?
Permit outbound TCP 443 from the task security group to the destination interface endpoint. Permit inbound TCP 443 on the endpoint security group from the task security group or appropriately restricted CIDR. Also inspect DNS, routes, and stateless NACL return traffic.
Why does ECS say secret ARN not found?
The referenced secret might not exist, might be in another Region, or might use an incorrect ARN or suffix. Confirm its identity and Region without exposing its plaintext value. Correct the task definition reference or restore the required secret.
Can I use the task role instead of the execution role for ECR?
The execution role is the identity ECS/Fargate uses to retrieve private ECR image authorization and perform other startup operations. The task role supplies credentials to application code inside the running container. Grant the permissions to the role involved in the failing phase.
Why does Fargate work in one subnet but fail in another?
The subnets may have different route tables, NACLs, or connectivity to interface endpoints and NAT gateways. ECS may place task attempts in either subnet when both are configured. Compare subnet-level network paths and test replacement tasks in the affected placement.
What is the difference between i/o timeout and AccessDenied in ECS?
A timeout typically points toward network reachability or response problems. AccessDenied means an authorization layer rejected the request, such as an IAM, resource, KMS, or endpoint policy. Start with the precise service and action shown in the detailed error.
How do I troubleshoot failed ECS tasks automatically?
Use the AWSSupport-TroubleshootECSTaskFailedToStart Systems Manager Automation runbook in the same Region as the failed task. It can inspect common IAM, networking, endpoint, secret, and logging problems. Review its resource creation and permission requirements before running it.
Why is my ECS task missing CloudWatch logs after ResourceInitializationError?
Your application may not have started, so no application logs exist yet. A failed awslogs initialization can also mean the CloudWatch Logs endpoint, log group, or execution-role permissions are incorrect. Inspect the stopped reason and log configuration before debugging application code.
Run one final startup check and keep the permanent fix
Before your final rollout, verify the same task-definition revision, execution role, image ARN, secret ARNs, subnet routes, and endpoint permissions that were involved in the failure. The task creation API response alone is no measure of success. Watch the replacement task reach RUNNING and pass its intended health checks. An application-level failure after startup is a new diagnostic branch, not proof that the original initialization fix was wrong.
Turn a one-time repair into a durable deployment change. Put corrected IAM statements into Terraform, CloudFormation, CDK, or your provisioning source rather than relying on an undocumented console edit. Preserve the route-table associations and endpoint security group rules in the same source of truth. A subsequent deployment should not silently replace the working configuration with the original error.
For teams, a small runbook with the task ARN, nested error string, execution-role field, and subnet decision table saves repeated detective work. Include the conditional endpoint set used by your own task, not a giant list copied from every AWS networking article. New developers should be able to tell whether the failure happened before the application process or after it started. That simple distinction prevents the most expensive debugging detours.
Jake can now keep his attention on appointments rather than chasing a database password inside a container that failed to launch. If your error still looks different after these fixes, save the new complete message and investigate that specific dependency. A precise error and a clear network map are much more useful than another broad IAM policy. Good luck getting your replacement task healthy without sacrificing the security of your VPC.
📌 If you keep one line from this page
A Fargate startup error is fixed by giving the execution role permission and the task network path to fetch the exact resource named in its stopped reason.
Revision note. Written October 15, 2026, with the Fargate 1.4.0 endpoint set and the AWSSupport runbook named. Without a bridge you cannot cross the river, says a Tamil proverb; give the task its route before you blame the container.