プレイヤーズ・ハイ

 雑多な日記

AWS IAM 用ツール Miam の雑なまとめ

※ かなり雑です.

【目次】

環境

RHEL 7.2 (64 bit)

Ruby と Miam のインストール

システムワイドにバコーンとインストール

$ sudo yum install ruby -y

$ ruby -v
ruby 2.0.0p648 (2015-12-16) [x86_64-linux]

$ gem -v
2.0.14.1

に,2.0 ... まぁいいやこのまま続けます.

$ sudo gem install miam
Fetching: jmespath-1.3.1.gem (100%)
Successfully installed jmespath-1.3.1
Fetching: aws-sigv4-1.0.0.gem (100%)
Successfully installed aws-sigv4-1.0.0
Fetching: aws-sdk-core-2.6.28.gem (100%)
Successfully installed aws-sdk-core-2.6.28
Fetching: ruby-progressbar-1.8.1.gem (100%)
Successfully installed ruby-progressbar-1.8.1
Fetching: parallel-1.10.0.gem (100%)
Successfully installed parallel-1.10.0
Fetching: tins-1.13.0.gem (100%)
Successfully installed tins-1.13.0
Fetching: term-ansicolor-1.4.0.gem (100%)
Successfully installed term-ansicolor-1.4.0
Fetching: diffy-3.1.0.gem (100%)
Successfully installed diffy-3.1.0
Fetching: hashie-3.4.6.gem (100%)
Successfully installed hashie-3.4.6
Fetching: miam-0.2.3.gem (100%)
Successfully installed miam-0.2.3
Parsing documentation for jmespath-1.3.1
Installing ri documentation for jmespath-1.3.1
Parsing documentation for aws-sigv4-1.0.0
Installing ri documentation for aws-sigv4-1.0.0
Parsing documentation for aws-sdk-core-2.6.28
Installing ri documentation for aws-sdk-core-2.6.28
Parsing documentation for ruby-progressbar-1.8.1
Installing ri documentation for ruby-progressbar-1.8.1
Parsing documentation for parallel-1.10.0
Installing ri documentation for parallel-1.10.0
Parsing documentation for tins-1.13.0
Installing ri documentation for tins-1.13.0
Parsing documentation for term-ansicolor-1.4.0
Installing ri documentation for term-ansicolor-1.4.0
Parsing documentation for diffy-3.1.0
Installing ri documentation for diffy-3.1.0
Parsing documentation for hashie-3.4.6
Installing ri documentation for hashie-3.4.6
Parsing documentation for miam-0.2.3
Installing ri documentation for miam-0.2.3
10 gems installed

$ echo $?
0

色々入った.

既存 IAM 設定のエクスポート

$ miam -e -o IAMfile

IAM 設定の適用

  • IAM 定義用 DSL ファイルを編集

$ vi IAMfile

  • ドライラン

$ miam -a --dry-run

  • 適用

$ miam -a

/usr/local/bin を環境変数 PATH に追加

あとは書き出された IAMfile, GitHub の IAMfile example を読み,Ruby のコードが読めれば大体わかるはず,という雑な説明ですみません.

Miam のオプション

これも GitHub の README.md を読めば大体わかると思いますがいくつか説明します.

--account-output FILE

?

--export-concurrency N

文字通り,export の多重度を上げるオプションです.

$ miam -e --export-concurrency 2 -o /tmp/IAMfile

--format=FORMAT

エクスポートするファイルのフォーマットを,Ruby ファイル形式,もしくは JSON 形式に指定します.

$ miam -e --export-concurrency 2 -o /tmp/IAMfile.rb --format=ruby
$ miam -e --export-concurrency 2 -o /tmp/IAMfile.json --format=json

--split

出力結果を分割します.IAM ユーザーとかグループとかロールとか.

$ miam -e --export-concurrency 2 -o /tmp/IAMfile.json --format=json --split
Export IAM
                                                                                                                                                                                                                                                          ᗧ 100%
  write `/tmp/users.iam.json`
  write `/tmp/groups.iam.json`
  write `/tmp/roles.iam.json`
  write `/tmp/instance_profiles.iam.json`
  write `/tmp/policies.iam.json`

--split-more

もっと分割します.1 IAM ユーザー毎とか.

--target REGEXP

?

適用範囲を正規表現で指定?

--ignore-login-profile

?

ヤツの名は Subiam

GREE さん製で,Miam からフォークした Subiam というのがあるそうなのでそっちも試してみます!!

Subiamを使いAWSのIAM管理をコードベースでおこなう | GREE Engineers' Blog http://labs.gree.jp/blog/2016/06/15988/

以上