Learning center

Find which ECS role signed an application's denied request

After a container starts, an AWS SDK call made by application code normally uses the task role when the SDK obtains credentials from ECS. The execution role serves ECS and its agent for launch operations such as pulling an image or fetching configured secrets.

In a fictional service, settlements starts successfully and then gets AccessDenied from SQS. The task definition ARN from the affected running task lets you inspect both roles for that revision.

aws ecs describe-task-definition --task-definition settlements:42 \
  --query 'taskDefinition.{application:taskRoleArn,execution:executionRoleArn}'

The audit event records a session of settlements-task. Compare its requested queue and operation with the task role's grants and the queue policy. An SDK with explicit credentials can use a different role, so use the audit event when it disagrees with the task definition. If the failure happened before the app started, match the ECS initialization error to the agent's operation instead. ECS task IAM role · ECS task execution role · DescribeTaskDefinition

For a failure during secret injection, see ECS secret startup errors.

Trace another denied request.

One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. Eligibility and fair-use terms.

Start free with GitHub

Related reading