0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

別アカウントのECRへ接続する方法(インターネットゲートウェイなし構成)

Posted at

はじめに

インターネットゲートウェイを使えない環境で、
踏み台EC2から別アカウントのECRへ接続したいという問い合わせがありました。

本記事では、VPCエンドポイント(Interface型)を利用して接続を実現した構成を紹介します。


構成概要

  • ECR:アカウントA
  • 踏み台EC2:アカウントB
  • 制約:インターネットゲートウェイ利用不可

問い合わせ時の構成

test411.drawio.png

問題点

アカウントAのVPCにあるECRエンドポイントを、
アカウントBから直接利用しようとしても通信できない


解決方法

アカウントB(踏み台側)にも、ECRのInterfaceエンドポイントを新規作成します。

サービス名 種類 用途
com.amazonaws.ap-northeast-1.ecr.api Interface 認証・API通信
com.amazonaws.ap-northeast-1.ecr.dkr Interface Docker通信

これにより、アカウントBのVPC内からPrivateLink経由でECRへアクセス可能になります。


ECRリポジトリ側の設定

アカウントAのECRに、アカウントBのアクセスを許可するポリシーを追加します。

  • Principal にアカウントBのIDを指定
  • ecr:GetAuthorizationTokenecr:BatchGetImage など必要なアクションを許可

接続確認

VPCエンドポイント経由でECR API・DKRにアクセス可能になり、
踏み台EC2から認証・プル・プッシュがすべて成功。


まとめ

項目 内容
IGW不要 PrivateLinkで閉域接続
別アカウントECR IAMポリシーで許可すればOK
必要なエンドポイント ecr.apiecr.dkr
ポイント アクセス元VPC側にもエンドポイントを設置すること
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?