Wondering how to allow ECS tasks to pull images from ECR image repository? We can help you.
Here, at Bobcares, we assist our customers with several AWS queries as part of our AWS Support Services.
Today, let us see how our Support techs assist with this query.
How to allow ECS tasks to pull images from ECR image repository?
Today, let us see the methods followed by our Support Techs.
For EC2 launch types
- Firstly, pen the AWS Identity and Access Management (IAM) console.
- In the navigation pane, choose Roles, and then choose Create role.
- Then, choose the AWS service role type, and then choose Elastic Container Service.
- In the Select your use case section, select EC2 Role for Elastic Container Service, and then choose Next: Permissions.
- Choose the default AmazonEC2ContainerServiceforEC2Role managed policy, and then choose Next: Tags.
Please note the AmazonEC2ContainerServiceforEC2Role policy also allows you to register container instances to your ECS cluster and enable log streams in Amazon CloudWatch. - Add tags to your policy, if desired, and then choose Next: Review.
- For Role name, enter a unique name (such as ECSRoleforEC2), and then choose Create role.
- Launch a new container instance using the latest Amazon ECS-optimized Amazon Linux AMI.
- Then, attach the role that you created to the new container instance.
- Next, create a task definition.
Important: In the containerDefinitions section of your task definition, specify the ECR image aws_account_id.dkr.ecr.region.amazonaws.com/repository:tag as the image property. - Finally, run a task or a service using the task definition that you created in step 10.
For Fargate launch types
An Amazon ECS task execution role is automatically created in the Amazon ECS console first-run experience.
If you can’t find the role or the role is deleted, complete the following steps:
- Firstly, open the IAM console.
- In the navigation pane, choose Roles, and then choose Create role.
- In the Select type of trusted entity section, choose Elastic Container Service.
- For Select your use case, choose Elastic Container Service Task, and then choose Next: Permissions.
- In the Attach permissions policy section, search for AmazonECSTaskExecutionRolePolicy, select the policy, and then choose Next: Review.
Note: This policy also provides permissions to use the awslogs log driver. - For the Role Name, enter ecsTaskExecutionRole, and then choose Create role.
- Create a task definition.
Important: In the containerDefinitions section of your task definition, specify the ECR image aws_account_id.dkr.ecr.region.amazonaws.com/repository:tag as the image property. - Run a task or a service using the task definition that you created in step 7.
[Need help with the process? We’d be happy to assist]
Conclusion
In short, we saw how our Support Techs allow ECS tasks to pull images from ECR image repository.
0 Comments