CloudMapper を使ってみた!!
CloudMapper とは
Duo が提供している
Amazon Web Services(AWS)環境を可視化するための Duo Securityの新しいオープンソースツール です。
( https://duo.com/blog/introducing-cloudmapper-an-aws-visualization-tool )
必要なソースを可視化する実行する環境(本ページではMac)にインストールし
IAM ユーザー(参照権限だけ)を用いて情報を取得し、jsonで加工して、それをブラウザで表示するようです。画像としてエクスポートも出来るようです。
Guthub のREADME を見ながらやってみます!
https://github.com/duo-labs/cloudmapper
準備
[実行環境]
- AWS
- MacBook
[AWS]
可視化したいアカウントIDの確認:
- Management Console から確認できるアカウントID(12桁)を控えておきます。
IAM ユーザーの準備:
- アクセスキーが必要となるため、ユーザーを作成します。
最小限はこれで良いそうです。これを見る限り、ec2、rds、ELBが対象のようで、かつ参照のみで良い模様。(≒ 扱えるサービス?)
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Resource": "*",
"Action": [
"ec2:DescribeRegions",
"ec2:DescribeAvailabilityZones",
"ec2:DescribeVpcs",
"ec2:DescribeSubnets",
"ec2:DescribeSecurityGroups",
"ec2:DescribeVpcPeeringConnections",
"ec2:DescribeInstances",
"ec2:DescribeNetworkInterfaces",
"rds:DescribeDBInstances",
"elasticloadbalancing:DescribeLoadBalancers"
]
}
]
}
[Mac]
Githubよりソースを取得するため、それが出来ないとエラーになります。
(たぶんアカウント取得と公開鍵の設定が必要)
- ソースをローカルへコピーします。
- brew で必要なモノをインストールしています。
$ git clone [email protected]:duo-labs/cloudmapper.git
Cloning into 'cloudmapper'...
remote: Counting objects: 779, done.
remote: Compressing objects: 100% (30/30), done.
remote: Total 779 (delta 19), reused 31 (delta 16), pack-reused 733
Receiving objects: 100% (779/779), 3.78 MiB | 965.00 KiB/s, done.
Resolving deltas: 100% (279/279), done.
$ brew install autoconf automake libtool jq
Warning: autoconf 2.69 is already installed
Warning: automake 1.15.1 is already installed
Warning: libtool 2.4.6_1 is already installed
Warning: jq 1.5_2 is already installed
$ virtualenv venv
New python executable in /Users/admin/venv/bin/python
Installing setuptools, pip, wheel...done.
$ source venv/bin/activate
$ cd cloudmapper
$ pip install -r requirements.txt
- 設定ファイルの修正
config.json_demo をコピーして、自分のアカウントIDと名前(自由)に切り替える。
$ cp config.json.demo config.json
$ vi conig.json
{ "accounts":
[
{"id": "123456789012", "name": "demo", "default": true}
],
"cidrs":
{
"1.1.1.1/32": {"name": "SF Office"},
"2.2.2.2/28": {"name": "NY Office"}
}
}
- AWS CLI のConfig 設定
先ほど作成したユーザーのアクセスキーやシークレットキーを設定する。
$ aws configure
実行
[情報保管のディレクトリ作成]
$ python cloudmapper.py gather --account-name "my_account"
* Getting region names
* Creating directory for each region name
* Getting VPC info
* Getting AZ info
* Getting Subnet info
* Getting EC2 info
* Getting RDS info
* Getting ELB info
* Getting Security Groups info
* Getting Network interface info
* Getting VPC Peering info
Complete
$ ls "my_accout"
ap-northeast-1 ap-southeast-2 eu-west-1 us-east-1
ap-northeast-2 ca-central-1 eu-west-2 us-east-2
ap-south-1 describe-regions.json eu-west-3 us-west-1
ap-southeast-1 eu-central-1 sa-east-1 us-west-2
[データー収集]
$ python cloudmapper.py prepare --account "my_account"
Building data for account "my_accout" ("account_id")
- 0 nodes built in region ap-south-1
- 0 nodes built in region eu-west-3
- 0 nodes built in region eu-west-2
- 0 nodes built in region eu-west-1
- 0 nodes built in region ap-northeast-2
- 2 nodes built in region ap-northeast-1
- 0 nodes built in region sa-east-1
- 0 nodes built in region ca-central-1
- 0 nodes built in region ap-southeast-1
- 0 nodes built in region ap-southeast-2
- 0 nodes built in region eu-central-1
- 0 nodes built in region us-east-1
- 0 nodes built in region us-east-2
- 0 nodes built in region us-west-1
- 0 nodes built in region us-west-2
- 0 external CIDRs built
- 0 connections built
Complete
[ブラウザ表示用サービス起動]
$ python cloudmapper.py serve
- 下記へアクセスする
http://127.0.0.1:8000/
Command Option
1.gather 編
$ python cloudmapper.py gather --help
usage: cloudmapper.py [-h] --account-name ACCOUNT_NAME
optional arguments:
-h, --help show this help message and exit
--account-name ACCOUNT_NAME
Account to collect from
2.prepare 編
$ python cloudmapper.py gather --account-name "my_account"
* Getting region names
* Creating directory for each region name
* Getting VPC info
* Getting AZ info
* Getting Subnet info
* Getting EC2 info
* Getting RDS info
* Getting ELB info
* Getting Security Groups info
* Getting Network interface info
* Getting VPC Peering info
Complete
$ ls "my_accout"
ap-northeast-1 ap-southeast-2 eu-west-1 us-east-1
ap-northeast-2 ca-central-1 eu-west-2 us-east-2
ap-south-1 describe-regions.json eu-west-3 us-west-1
ap-southeast-1 eu-central-1 sa-east-1 us-west-2
$ python cloudmapper.py prepare --account "my_account"
Building data for account "my_accout" ("account_id")
- 0 nodes built in region ap-south-1
- 0 nodes built in region eu-west-3
- 0 nodes built in region eu-west-2
- 0 nodes built in region eu-west-1
- 0 nodes built in region ap-northeast-2
- 2 nodes built in region ap-northeast-1
- 0 nodes built in region sa-east-1
- 0 nodes built in region ca-central-1
- 0 nodes built in region ap-southeast-1
- 0 nodes built in region ap-southeast-2
- 0 nodes built in region eu-central-1
- 0 nodes built in region us-east-1
- 0 nodes built in region us-east-2
- 0 nodes built in region us-west-1
- 0 nodes built in region us-west-2
- 0 external CIDRs built
- 0 connections built
Complete
$ python cloudmapper.py serve
1.gather 編
$ python cloudmapper.py gather --help
usage: cloudmapper.py [-h] --account-name ACCOUNT_NAME
optional arguments:
-h, --help show this help message and exit
--account-name ACCOUNT_NAME
Account to collect from
2.prepare 編
--collapse-by-tag COLLAPSE_BY_TAG は後ほど見てみます!
$ python cloudmapper.py prepare --help
usage: cloudmapper.py [-h] [--config CONFIG] [--account-name ACCOUNT_NAME]
[--regions REGIONS] [--internal-edges]
[--no-internal-edges] [--inter-rds-edges]
[--no-inter-rds-edges] [--read-replicas]
[--no-read-replicas] [--azs] [--no-azs]
[--collapse-by-tag COLLAPSE_BY_TAG]
optional arguments:
-h, --help show this help message and exit
--config CONFIG Config file name
--account-name ACCOUNT_NAME
Account to collect from
--regions REGIONS Regions to restrict to (ex. us-east-1,us-west-2)
--internal-edges Show all connections (default)
--no-internal-edges Only show connections to external CIDRs
--inter-rds-edges Show connections between RDS instances
--no-inter-rds-edges Do not show connections between RDS instances
(default)
--read-replicas Show RDS read replicas (default)
--no-read-replicas Do not show RDS read replicas
--azs Show availability zones (default)
--no-azs Do not show availability zones
--collapse-by-tag COLLAPSE_BY_TAG
Collapse nodes with the same tag to a single node
3.serve 編
$ python cloudmapper.py serve --help
usage: cloudmapper.py [-h] [--port PORT] [--public]
optional arguments:
-h, --help show this help message and exit
--port PORT Port to listen on (default: 8000)
--public Allow connections from 0.0.0.0 as opposed to only localhost
(default: False)
やってみたこと
1. Cloudformationのサンプル(LAMP Stack)
2. 同一VPCに多数環境がある場合、何かで区別出来るか?
出来ない模様です。
3. 複数VPCがある場合はどう見えるか?
普通に、別物として表示されます。
4. 停止しているインスタンスはどうなるか?
表示されない。
5. よくある構成イメージ
6. VPC エンドポイント系は?
- DynamoDB:表示されず
- S3:表示されず
7. prepare コマンドのオプション(--collapse-by-tag COLLAPSE_BY_TAG)
タグのKEYを指定すると値が一緒のものは、統合される。
統合されたインスタンスは、Nameだけ表示されていて残念…
8. Inter-Region VPC Peering はどうだろう?
内部通信は表示されない。(web間でセキュリティグループは許可してる)
34.218.51.109/32 はOregon側のwebサーバのEIP。
ユースケース
VPCのネットワークレベル(おそらくENI)で情報収集して、表示しているように見れ受けられる。
なので、S3やLambdaなどの構成には適していない。
とはいえ、システムが大きくなると、こういった通信設定を可視化・管理するのは
困難なため、とても重宝されるのではないか?と個人的には思う。
まとめ
ざっくりみた・試してみたいサービス一覧
Service | 対応 | Memo |
---|---|---|
EC2 | ○ | |
ECS | ○ | |
Lambda | × | |
EB | ○ | |
AutoScailing | ○ | |
S3 | × | |
RDS | ○ | |
RDS Aurora | ○ | |
DynamoDB | × | |
Redshift | × | |
ElastiCache | × | |
VPC | ○ | |
VPC(Endpoint) | × | |
VPC(Peering) | × | |
DirectConnect&VPN | ? | 試して良い環境が今ない… |
実行環境
macOSの場合:
Linuxの場合:
Mac か Linux へのインストールが紹介されている。
Windowsユーザはどうすんだ?と思ったのですが、別に自分のPCから実行しなくて良い気がしました。
EC2で、Linux立ち上げで実行する方が、Userを発行せずに、Roleだけ済んでセキュアだと思う。
参考URL
- AWSのシステム構成情報を集めて構成図を自動生成してくれる「CloudMapper」、オープンソースで公開。
http://www.publickey1.jp/blog/18/awscloudmapper.html
Author And Source
この問題について(CloudMapper を使ってみた!!), 我々は、より多くの情報をここで見つけました https://qiita.com/bee3/items/fcbbdb417536c1347bc2著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .