내용으로 건너뛰기

Private ECR 이미지 pull시 Privatelink 유무에 따른 NW Flow

0
  1. Amazion ECS Task에서 Private ECR의 이미지를 Pull은 동일 어카운트 내에 있는 ECR의 이미지만 다운로드 가능하고, IAM 정책만 있으면 task execute role만 있어도 가능한것일까요? 기술적으로 어떻게 설정해야한지 세부적으로 설명 부탁드립니다.

1-1. 랜딩존 환경에서 A 어카운트에서 B 어카운트의 Private ECR 이미지를 Pull할 수 있는지? 가능하다면 어떻게해야되는지 1-2. 다른 회사의 어카운트에 설정된 Private ECR 이미지를 우리 회사의 어카운트의 Pull할 수 있는지? 가능하다면 어떻게해야되는지

  1. Private ECR 이미지 pull시 VPC 엔드포인트의 Privatelink 설정 유무에 따라 네트워 플로우가 어떻게 흐르는지 궁금합니다. 아래는 제가 생각했을때 예시이며 세부적으로 궁금합니다. (Privatelink 설정시) AWS 어카운트 내 VPC -> AWS 리전 내부 통신 -> 11111111.dkr.ecr.ap-northeast-2.amazonaws.com/hc-test-api의 AWS 내부 IP (Privatelink 미설정시) AWS 어카운트 내 VPC -> NAT GW -> 외부 인터넷망 -> 11111111.dkr.ecr.ap-northeast-2.amazonaws.com/hc-test-api
1개 답변
0

Amazon ECS Task and Private ECR Image Pull Configuration

Same Account ECR Image Pull

Yes, an Amazon ECS task can pull images from a private ECR repository in the same account with the proper IAM permissions. The ECS task execution role needs the following permissions:

  • ecr:GetDownloadUrlForLayer
  • ecr:BatchGetImage
  • ecr:BatchCheckLayerAvailability

These permissions are typically included in the AmazonECSTaskExecutionRolePolicy managed policy. When you create an ECS task definition, you specify the task execution role that has these permissions.

Cross-Account ECR Image Pull

1-1. Landing Zone Environment (Account A pulling from Account B)

Yes, you can pull ECR images across accounts within your organization. To do this:

  1. In Account B (image owner):
  • Create a resource-based policy on the ECR repository that grants permission to Account A
  • Example policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowCrossAccountPull",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::ACCOUNT-A-ID:root"
},
"Action": [
"ecr:BatchGetImage",
"ecr:GetDownloadUrlForLayer",
"ecr:BatchCheckLayerAvailability"
]
}
]
}
  1. In Account A (image consumer):
  • Ensure the ECS task execution role has permissions to pull from the cross-account repository
  • Reference the full ECR image URI in your task definition: ACCOUNT-B-ID.dkr.ecr.region.amazonaws.com/repository-name:tag

1-2. Cross-Organization ECR Image Pull

Yes, you can pull ECR images from another organization's account with proper permissions:

  1. In the external organization's account:
  • They must add a resource-based policy to their ECR repository that explicitly grants your account access
  • Similar to the cross-account policy above, but with your organization's account ID
  1. In your account:
  • Your ECS task execution role needs the same permissions as mentioned earlier
  • Reference the full ECR image URI in your task definition

This approach works across any AWS accounts, regardless of organizational relationship, as long as proper permissions are granted.

Network Flow with and without PrivateLink

With PrivateLink (VPC Endpoint for ECR)

When you have PrivateLink configured for ECR:

  1. The ECS task in your VPC initiates a request to pull an image
  2. The request goes through the VPC endpoint for ECR (com.amazonaws.region.ecr.dkr)
  3. Traffic stays within the AWS network backbone and never leaves the AWS network
  4. The ECR service processes the request and returns the image through the same private connection

This provides enhanced security as traffic doesn't traverse the public internet, and you maintain enterprise-grade security through IPv6-aware security groups and VPC Flow Logs monitoring.

Without PrivateLink

Without PrivateLink configured:

  1. The ECS task in your VPC initiates a request to pull an image
  2. The request is routed to a NAT Gateway (if in a private subnet) or directly (if in a public subnet)
  3. Traffic exits your VPC and traverses the public internet
  4. The request reaches the ECR service endpoint (11111111.dkr.ecr.ap-northeast-2.amazonaws.com/hc-test-api)
  5. The response follows the same path back

This approach exposes your traffic to the public internet, which may have security and performance implications.

Using PrivateLink is recommended for enhanced security, reduced latency, and improved reliability when working with ECR images, especially in production environments.
Sources
Amazon ECS announces IPv6-only support | Containers
SEC09-BP03 Authenticate network communications - AWS Well-Architected Framework

답변함 6달 전

AWS
지원 엔지니어

검토됨 6달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

관련 콘텐츠