[新機能] Amazon InspectorエージェントがProxy利用に対応しました

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

はじめに

今日ご紹介する新機能はこちらです。

これまでAmazon Inspectorのドキュメントには以下の記載がありました。

EC2 インスタンスで、インターネットに接続するためにプロキシサーバーが必要な場合、これらのインスタンスで実行している Amazon Inspector エージェントは Amazon Inspector サービスエンドポイントに接続することができません。これは、Amazon Inspector エージェントのプロキシサポートが現在利用できないためです。

今回のアップデートで、インターネットに接続するためにプロキシサーバーが必要な場合であっても、設定によりAmazon InspectorエージェントがAmazon Inspectorサービスエンドポイントに接続できるようになりました。具体的な手順は以下ドキュメントに記載があります。

ということで早速やってみました。

やってみた

構成

以下の通り。デフォルトゲートウェイをInternet Gatewayに向けているPublicサブネットにProxyサーバとなっているEC2があり、デフォルトゲートウェイを持たないPrivateサブネットにAmazon InspectorエージェントがインストールされたEC2があります。

AWS Design

Amazon Inspectorエージェントのインストール

Amazon Inspectorのインストールスクリプトの中でyumが実行されるので、yumでProxyを経由するように設定しておきます。当然ですがyum -y updateしておきましょう。

$ sudo vi /etc/yum.conf
# 以下の行を追加
proxy=http://<ProxyサーバのIPアドレス>:3128

curlでAmazon Inspectorのインストールスクリプトを取得...するのですが、そもそもcurlもProxyを経由しないといけないので、以下の通り-xオプションでProxyを指定します。

$ curl -x <ProxyサーバのIPアドレス>:3128 -O https://d1wk0tztpsntt1.cloudfront.net/linux/latest/install

取得したインストールスクリプトを実行します。

$ sudo bash install
Distribution of the machine is Amazon Linux AMI.
Distribution type of the machine is amzn.
Revision of the distro is 2016.09.
Kernel version of the machine is 4.4.41-36.55.amzn1.x86_64.
ip-172-31-37-122.ap-northeast-1.compute.internal is an EC2 instance reporting region as ap-northeast-1.
Check for existing AwsAgent completed with error code:0
Existing version of agent installed is 0.0.0.0.
Check for existing AwsAgentKernelModule completed with error code:0
Existing version of kernel module installed is 0.0.0.0.

...ここで停止してしまいました。そもそもProxy経由でしかインターネットに接続出来ない場合、Agentのインストール自体が出来ません。

Proxyを使うための設定

/etc/init.d/awsagent.envを作成します。

$ sudo vi /etc/init.d/awsagent.env

内容は以下の通りです。169.254.169.254はインスタンスメタデータのエンドポイントなので除外の設定を行います。

export https_proxy=https://<ProxyサーバのIPアドレス>:3128
export http_proxy=http://<ProxyサーバのIPアドレス>:3128
export no_proxy=169.254.169.254

Amazon Inspectorエージェントのインストール(再チャレンジ)

改めて取得したインストールスクリプトを実行します。

$ sudo bash install
Distribution of the machine is Amazon Linux AMI.
Distribution type of the machine is amzn.
Revision of the distro is 2016.09.
...snip...
Current running agent reports to arsenal endpoint:
Current running agent reports version as: 1.0.800.1
This install script was created to install agent version:1.0.800.1
In most cases, these version numbers should be the same.

インストールが完了しました!あとは通常通りAmazon Inspectorを運用するだけです!

さいごに

インターネットへの直接経路を持たせないような機密性の高いシステムであっても、Proxyを経由することでAmazon Inspectorが使えます。これでInspectorの活躍の幅が広がります。Amazon Inspectorは本当に良いサービスで、全てのシステムにデフォルトで導入しても良いくらいだと考えています。ぜひ使ってみてください!