Search code examples
amazon-web-servicesamazon-iamamazon-ecs

ECS: TaskExecutionRole for container


I want to create a ECS Task of Fargate type via CloudFormation, but when uploading this manifest:

Resources:
  UITaskDefinition:
    Type: AWS::ECS::TaskDefinition
    Properties:
      Family: "ui-task"
      NetworkMode: "awsvpc"
      Cpu: "256"
      Memory: "0.5GB"
      RequiresCompatibilities: 
        - "FARGATE"
      ContainerDefinitions:
        -
          Name: !Ref UIContainerName
          Image: "298984380.dkr.ecr.eu-west-1.amazonaws.com/myregistry/ui:test"
          Essential: "true"
          PortMappings:
          -
            ContainerPort: 80
            HostPort: 80

I get the following error

Fargate requires task definition to have execution role ARN to support ECR images

However, when I am trying to create the role via the AWS console, I am prompted with the following service list for the role to be assigned to

enter image description here

Which service should I choose? Elastic Container Service?

I thought the role was container-specific!


Solution

  • Yes, you can choose Elastic Container Service for the trusted entity. Detailed instructions and information about the execution role can be found in the ECS documentation.