Search code examples
amazon-web-servicesamazon-ecsaws-fargateaws-event-bridge

ECS Fargate Task in EventBridge fails with ResourceInitializationError


I have created an ECS Fargate Task, which I can manually run. It updates a Dynomodb and I get logs.

Now I want this to run on a schedule. I have setup a scheduled ECS task through EventBridge. However, this does not run.

My looking at the EventBridge logs I can see that the container has been stopped for the following stopped reason:

ResourceInitializationError: unable to pull secrets or registry auth: execution resource 
retrieval failed: unable to retrieve ecr registry auth: service call has been retried 3
time(s): RequestError: send request failed caused by: Post https://api.ecr....

I thought this might be a problem with permissions. However, I tested giving the Task Execution Role full power user permissions and I still get the same error. Could the problem be something else?


Solution

  • I fixed this by enabling auto-assign public IP.

    However, to do this, I had to first change from "Capacity provider strategy" - "Use cluster default", to "Launch type" - "FARGATE". Then the option to enable auto-assign public IP became available in the dropdown in the EventBridge UI.

    This seems odd to me, because my default capacity provider strategy for my cluster is Fargate. But it is working now.