CodexBloom - Programming Q&A Platform

AWS ECS Task implementing in 'PENDING' State When Trying to Scale Up with Fargate

πŸ‘€ Views: 19 πŸ’¬ Answers: 1 πŸ“… Created: 2025-06-09
aws ecs fargate docker ecr json

I'm writing unit tests and I keep running into I'm updating my dependencies and I'm attempting to set up I'm stuck on something that should probably be simple..... I'm currently working with an scenario while trying to scale my AWS ECS service using Fargate. The service is set up correctly, and my task definition has been running fine for a while. However, when I attempt to scale the service from 2 to 4 tasks, they remain in the 'PENDING' state indefinitely. I checked the service events and found the following behavior message: 'Task failed to start. behavior: want to pull container image'. I have verified that the image URI in the task definition is correct, and the image exists in ECR. Also, I ensured that the Fargate launch type is selected. Here’s a relevant snippet of my task definition: ```json { "family": "my-task", "containerDefinitions": [ { "name": "my-container", "image": "123456789012.dkr.ecr.us-west-2.amazonaws.com/my-repo:latest", "memory": 512, "cpu": 256, "essential": true, "portMappings": [ { "containerPort": 80, "hostPort": 80 } ] } ] } ``` I also ensured that the IAM role associated with the ECS task has permissions to access ECR. The role includes the following policy: ```json { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "ecr:GetAuthorizationToken", "ecr:BatchCheckLayerAvailability", "ecr:GetDownloadUrlForLayer", "ecr:BatchGetImage" ], "Resource": "*" } ] } ``` Despite this, the tasks are still not starting. I've tried redeploying the service, updating the task definition, and checking the event logs, but nothing seems to work. Any idea why my tasks are exploring in 'PENDING' and how I can resolve this scenario? Any help would be greatly appreciated! I'm on CentOS using the latest version of Json. What's the best practice here? What are your experiences with this? For context: I'm using Json on Ubuntu 22.04. Thanks for any help you can provide! Thanks for taking the time to read this!