プライベートサブネットのEC2インスタンスはAmazonリポジトリにアクセスできません

ダニエル

ECSクラスターを作成しようとしていますが、3つのパブリックサブネットと3つのプライベートサブネットを使用してVPCを手動で構築しました。3つのパブリックサブネットすべてに0.0.0.0/0でIGWが接続されており、3つのプライベートサブネットすべてに0.0.0.0/0でルートテーブルに接続されたNATゲートウェイがあります。3つのNATゲートウェイはそれぞれ、各パブリックサブネットにあります。

現在使用しようとしているのと同じCloudFormationテンプレートを使用して別のECSクラスターを既に作成しましたが、すべて正常に機能しました。

1番目と2番目のVPC(失敗したもの)の設定を比較しましたが、すべての設定(IGW、NATゲートウェイ、ルートテーブル、NACL、SG)は同じですが、もちろんIPは2番目のVPCのIPに調整されます。2番目のVPCでECSを作成しようとすると(1つ失敗)、プライベートサブネットのEC2インスタンスがAmazonリポジトリに接続できず、EC2インスタンスからの信号がAuto Scaling Groupに送信されないため、スタック全体がロールバックされます。

その後、EC2インスタンスからのシステムログを確認しましたが、Amazonエージェントをインストールできません。ログからの抜粋は次のとおりです。

Starting cloud-init: Cloud-init v. 0.7.6 running 'modules:config' at Mon, 20 Aug 2018 06:38:04 +0000. Up 10.06 seconds.
Loaded plugins: priorities, update-motd, upgrade-helper


 One of the configured repositories failed (Unknown),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Disable the repository, so yum won't use it by default. Yum will then
        just ignore the repository until you permanently enable it again or use
        --enablerepo for temporary usage:

            yum-config-manager --disable <repoid>

     4. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true

Cannot find a valid baseurl for repo: amzn-main/latest
Could not retrieve mirrorlist http://repo.eu-central-1.amazonaws.com/latest/main/mirror.list error was
12: Timeout on http://repo.eu-central-1.amazonaws.com/latest/main/mirror.list: (28, 'Connection timed out after 5001 milliseconds')
Aug 20 06:38:20 cloud-init[2116]: util.py[WARNING]: Package upgrade failed
Aug 20 06:38:20 cloud-init[2116]: cc_package_update_upgrade_install.py[WARNING]: 1 failed with exceptions, re-raising the last one
Aug 20 06:38:20 cloud-init[2116]: util.py[WARNING]: Running module package-update-upgrade-install (<module 'cloudinit.config.cc_package_update_upgrade_install' from '/usr/lib/python2.7/dist-packages/cloudinit/config/cc_package_update_upgrade_install.pyc'>) failed
Generating SSH2 ED25519 host key: [  OK  ]

Starting sshd: [  OK  ]

ntpdate: Synchronizing with time server: [  OK  ]

Starting ntpd: [  OK  ]

Starting sendmail: [  OK  ]

Starting sm-client: [  OK  ]

Starting crond: [  OK  ]

Starting cgconfig service: [  OK  ]

Starting docker:    .[  OK  ]

Starting cloud-init: Cloud-init v. 0.7.6 running 'modules:final' at Mon, 20 Aug 2018 06:38:25 +0000. Up 29.91 seconds.
Loaded plugins: priorities, update-motd, upgrade-helper
Examining /var/tmp/yum-root-i85tqq/amazon-ssm-agent.rpm: amazon-ssm-agent-2.3.13.0-1.x86_64
Marking /var/tmp/yum-root-i85tqq/amazon-ssm-agent.rpm to be installed
Resolving Dependencies


 One of the configured repositories failed (Unknown),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Disable the repository, so yum won't use it by default. Yum will then
        just ignore the repository until you permanently enable it again or use
        --enablerepo for temporary usage:

            yum-config-manager --disable <repoid>

     4. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true

Cannot find a valid baseurl for repo: amzn-main/latest
Could not retrieve mirrorlist http://repo.eu-central-1.amazonaws.com/latest/main/mirror.list error was
12: Timeout on http://repo.eu-central-1.amazonaws.com/latest/main/mirror.list: (28, 'Connection timed out after 5000 milliseconds')
Loaded plugins: priorities, update-motd, upgrade-helper
[   53.291581] bridge: filtering via arp/ip/ip6tables is no longer available by default. Update your scripts to load br_netfilter if you need this.
[   53.297948] Bridge firewalling registered
[   53.304776] nf_conntrack version 0.5.0 (65536 buckets, 262144 max)
[   53.318481] ip_tables: (C) 2000-2006 Netfilter Core Team
[   53.510300] Initializing XFRM netlink socket
[   53.515251] Netfilter messages via NETLINK v0.30.
[   53.518920] ctnetlink v0.93: registering with nfnetlink.
[   53.688086] IPv6: ADDRCONF(NETDEV_UP): docker0: link is not ready


 One of the configured repositories failed (Unknown),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Disable the repository, so yum won't use it by default. Yum will then
        just ignore the repository until you permanently enable it again or use
        --enablerepo for temporary usage:

            yum-config-manager --disable <repoid>

     4. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true

Cannot find a valid baseurl for repo: amzn-main/latest
Could not retrieve mirrorlist http://repo.eu-central-1.amazonaws.com/latest/main/mirror.list error was
12: Timeout on http://repo.eu-central-1.amazonaws.com/latest/main/mirror.list: (28, 'Connection timed out after 5000 milliseconds')
Loaded plugins: priorities, update-motd, upgrade-helper


 One of the configured repositories failed (Unknown),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Disable the repository, so yum won't use it by default. Yum will then
        just ignore the repository until you permanently enable it again or use
        --enablerepo for temporary usage:

            yum-config-manager --disable <repoid>

     4. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true

Cannot find a valid baseurl for repo: amzn-main/latest
Could not retrieve mirrorlist http://repo.eu-central-1.amazonaws.com/latest/main/mirror.list error was
12: Timeout on http://repo.eu-central-1.amazonaws.com/latest/main/mirror.list: (28, 'Connection timed out after 5001 milliseconds')
/var/lib/cloud/instance/scripts/part-001: line 9: /opt/aws/bin/cfn-init: No such file or directory
/var/lib/cloud/instance/scripts/part-001: line 10: /opt/aws/bin/cfn-signal: No such file or directory
Aug 20 06:39:13 cloud-init[2286]: util.py[WARNING]: Failed running /var/lib/cloud/instance/scripts/part-001 [127]
Aug 20 06:39:13 cloud-init[2286]: cc_scripts_user.py[WARNING]: Failed to run module scripts-user (scripts in /var/lib/cloud/instance/scripts)
Aug 20 06:39:13 cloud-init[2286]: util.py[WARNING]: Running module scripts-user (<module 'cloudinit.config.cc_scripts_user' from '/usr/lib/python2.7/dist-packages/cloudinit/config/cc_scripts_user.pyc'>) failed

NACLを確認しました。インバウンドとアウトバウンドについては、すべてが0.0.0.0/0に設定されており、ALLOWです。

1番目のVPCには、ECSに最適化されたAMIとt2.large(問題なし)を使用し、2番目のc5.xlarge(問題の原因)には使用しています。

EC2がAmazonリポジトリに到達できない原因は何ですか?

編集

そのため、後で2番目のVPCにS3エンドポイントが接続されていることがわかりました。もう少し調べてみると、LinkedInに次のような素敵な投稿が見つかりました。

Amazon LinuxリポジトリはS3でホストされているため、S3エンドポイントポリシーでリポジトリへのアクセスを許可する必要があります。

したがって、yumを起動すると、ローカルDNSトリックの魔法を使用して、内部S3エンドポイントにルーティングします。

CloudFormationテンプレートを更新し、以下のLaunchConfigurationにポリシーを追加しましたが、それは役に立ちませんでした。

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": [
                "s3:Get*",
                "s3:List*"
            ],
            "Resource": [
                "arn:aws:s3:::repo.eu-central-1.amazonaws.com",
                "arn:aws:s3:::repo.eu-central-1.amazonaws.com/*"
            ],
            "Effect": "Allow"
        }
    ]
}

また、エンドポイントポリシーは次のようになります。

{
    "Statement": [
        {
            "Action": "*",
            "Effect": "Allow",
            "Resource": "*",
            "Principal": "*"
        }
    ]
}
ダニエル

最後に、AWSコンソールのすべてのセクションを調べた後、問題の原因を突き止めました。元の投稿の更新ですでに述べたように、EndpointがVPCに接続されると、EC2はパッケージとリポジトリを内部で解決しようとします。エンドポイントのすべての設定を確認したところ、エンドポイントに追加されたパブリックサブネットのルートテーブルのみが見つかりました。プライベートサブネットも追加した後、EC2インスタンスがパッケージとリポジトリに到達できることがわかりました。

ここに画像の説明を入力してください

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

サブクラスインスタンスを介して自身のクラスからプライベート変数にアクセスできません

VPCのプライベートサブネットにあるEC2インスタンスのAmazon ELB

Amazon EC2:パブリックIPなしのパブリックサブネットワークでのインスタンスとプライベートサブネットワークでのインスタンス

GoogleColabはGithubプライベートリポジトリにアクセスできません

プライベートサブネットのEC2インスタンスによって公開されたWebApplicationへのアクセス

プライベートVPCサブネットのEC2インスタンスでユーザーデータが実行されていません

リリースapkでリモートAPIにアクセスできません。アプリにはインターネット権限があります

awsセキュリティグループ:ec2インスタンスが独自のポートにアクセスできるようにする

パブリックサブネットのAWSLambdaはインターネットにアクセスできません

プライベートEC2インスタンスの任意のリージョンからsqsキューにアクセスする方法

イオンコンデンサAndroidアプリはインターネットにアクセスできません

openvpnネットワークのリモートマシンからプライベートホスト名を使用してAWSのec2インスタンスにアクセスします

同じAWSElasticIPをパブリックサブネットのNATゲートウェイとEC2インスタンスで共有できますか?

プライベートサブネット内のラムダは、パブリックサブネット内のEC2にどのようにアクセスできますか?

プライベートIPを介して同じVPC内のEC2インスタンスにアクセスできません

パブリックサブネットのEC2インスタンスにはパブリックIPがありません

別のポートのインターネットからcentOSにデプロイされたmeteorアプリにアクセスできません

オブジェクトポインタの2D配列のクラスメンバーにアクセスできません(タイプ***)

サーブレットフィルタは、JSFベースのアプリケーションのCSS、リソース、およびプライムフェイスにアクセスできません

Webmin インターフェイスを使用していくつかのセキュリティ更新を行った後、Ubuntu 16.04 AWS EC2 サーバーからインターネットにアクセスできません

ObjectListView の CellEditFinished イベント ポップアップ メッセージで破棄されたオブジェクトにアクセスできません。

AWS: パブリック サブネットの EC2 は、プライベート サブネットの EC2 に ping できない

ハイブクライアントモードのkylinはリモートデータベースにアクセスできません

Rの更新後にパッケージをインストールできません:リポジトリのインデックスにアクセスできません:インターネットルーチンをロードできません

<AWSVPC>パブリックサブネットインスタンスからプライベートサブネットインスタンスにpingを実行できません

ジップスターエラー!エンティティジェネレータは、現時点ではsqlタイプのデータベースを使用するリアクティブアプリをサポートしていません

Dartライブラリのプライベートメソッドにアクセスできません

カスタムvpcのパブリックサブネット内のEC2インスタンスにSSH接続できません

VPCエンドポイントのプライベートリンクを使用してプライベートサブネットのIAMAWSサービスエンドポイントにアクセスできません

TOP 一覧

  1. 1

    Unity:未知のスクリプトをGameObject(カスタムエディター)に動的にアタッチする方法

  2. 2

    セレンのモデルダイアログからテキストを抽出するにはどうすればよいですか?

  3. 3

    Ansibleで複数行のシェルスクリプトを実行する方法

  4. 4

    tkinterウィンドウを閉じてもPythonプログラムが終了しない

  5. 5

    Crashlytics:コンパイラー生成とはどういう意味ですか?

  6. 6

    GoDaddyでのCKEditorとKCfinderの画像プレビュー

  7. 7

    Windows 10 Pro 1709を1803、1809、または1903に更新しますか?

  8. 8

    Chromeウェブアプリのウェブビューの高さの問題

  9. 9

    モーダルダイアログを自動的に閉じる-サーバーコードが完了したら、Googleスプレッドシートのダイアログを閉じます

  10. 10

    Windows 10の起動時間:以前は20秒でしたが、現在は6〜8倍になっています

  11. 11

    Reactでclsxを使用する方法

  12. 12

    ファイル内の2つのマーカー間のテキストを、別のファイルのテキストのセクションに置き換えるにはどうすればよいですか?

  13. 13

    MLでのデータ前処理の背後にある直感

  14. 14

    グラフからテーブルに条件付き書式を適用するにはどうすればよいですか?

  15. 15

    Pythonを使用して同じ列の同じ値の間の時差を取得する方法

  16. 16

    mutate_allとifelseを組み合わせるにはどうすればよいですか

  17. 17

    ネットワークグラフで、ネットワークコンポーネントにカーソルを合わせたときに、それらを強調表示するにはどうすればよいですか?

  18. 18

    テキストフィールドの値に基づいて UIslider を移動します

  19. 19

    BLOBストレージからデータを読み取り、Azure関数アプリを使用してデータにアクセスする方法

  20. 20

    PowerShellの分割ファイルへのヘッダーの追加

  21. 21

    ソートされた検索、ターゲット値未満の数をカウント

ホットタグ

アーカイブ