I am trying to set up a ECS but so far I have encountered a few permission issue for which I have created some questions on this forum already.
I think I am stuck so far because honestly I cannot find out all these role requirements in one place concisely.
It seems like I need to define at least two roles:
1) ECS container http://docs.aws.amazon.com/AmazonECS/latest/developerguide/instance_IAM_role.html
2) ECS task http://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-iam-roles.html#enable_task_iam_roles
Is it correct?
Did I miss out anything? Is there any special IAM requirement?
The only necessary role is the Container Instance IAM role. This role allows the ECS agent (running on your EC2 instance) to communicate with Amazon ECS.
There are five other roles that you may also find useful, for different purposes:
FARGATE
launch type. This role enables AWS Fargate to pull your container images from Amazon ECR and to forward your logs to Amazon CloudWatch Logs. This role is also used (on both the Fargate and the EC2 launch types) to enable private registry authentication and secrets from AWS Secrets Manager and AWS Systems Manager Parameter Store.Using my Administrator role, when creating an ECS Cluster, I too was blocked by... "ECS Cluster Unable to assume the service linked role. Please verify that the ECS service linked role exists."
And I verified that indeed the role, AWSServiceRoleForECS, existed.
The Fix? By exercising the "Get Started" wizard, it (re)configured something under the covers and now my Administrator roles is allowed to assume AWSServiceRoleForECS and successfully creates cluster.
In addition to this very good explanation of @samuel-karp, today I ran into a problem when migrating from classic ELB to the ALB in combination of custom
task_role_arn
for ECS services.Although I followed the instructions described behind the link
Task IAM role
, the Error wasThe thing is that the service seems to register itself at the load balancer. It only worked when I exchanged the Principal from
ecs.amazonaws.com
to"Principal": { "Service": "ecs-tasks.amazonaws.com" }