AWS CredentialProviders fail to retrieve credentials in Fargate

Question:

I’m running a SpringBoot app in AWS Fargate that uses SecretsManager. This is the what I supply to the AWS SDK as credential providers:

and this allows me to run this application locally with an alternative AWS profile. When I run this app in Fargate though, I get the following stacktrace:

This is an extract of my task-definition.json:

with this in the ‘trust relationship’:

and attached policy AmazonECSTaskExecutionRolePolicy (no permission boundary set).
Any help would be great, thanks.

Answer:

You need to assign a task role. The execution role is what gives ECS access to resources like ECR and SecretsManager in order to execute your ECS task. The task role is what gives your task’s code access to other AWS resources. See the documentation here.

Leave a Reply