2015年3月13日金曜日

MacにAWS CLIをインストールする方法

pipのインストール

easy_installでpipをインストールします。

pipはphysonのパッケージ管理ソフト

以下を実行します。パスワードが求められるの合わせて入力します。

sudo easy_install pip
Password:

pipのインストールの確認

以下を実行して

pip -h

以下のようにUsageが出力されれば成功です。

Usage:
  pip <command> [options]

Commands:
  install                     Install packages.
  uninstall                   Uninstall packages.
  freeze                      Output installed packages in requirements format.
  list                        List installed packages.
  show                        Show information about installed packages.
  search                      Search PyPI for packages.
  wheel                       Build wheels from your requirements.
  zip                         DEPRECATED. Zip individual packages.
  unzip                       DEPRECATED. Unzip individual packages.
  help                        Show help for commands.

General Options:
  -h, --help                  Show help.
  --isolated                  Run pip in an isolated mode, ignoring environment variables and user configuration.
  -v, --verbose               Give more output. Option is additive, and can be used up to 3 times.
  -V, --version               Show version and exit.
  -q, --quiet                 Give less output.
  --log <path>                Path to a verbose appending log.
  --proxy <proxy>             Specify a proxy in the form [user:passwd@]proxy.server:port.
  --retries <retries>         Maximum number of retries each connection should attempt (default 5 times).
  --timeout <sec>             Set the socket timeout (default 15 seconds).
  --exists-action <action>    Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup.
  --trusted-host <hostname>   Mark this host as trusted, even though it does not have valid or any HTTPS.
  --cert <path>               Path to alternate CA bundle.
  --client-cert <path>        Path to SSL client certificate, a single file containing the private key and the certificate in PEM format.
  --cache-dir <dir>           Store the cache data in <dir>.
  --no-cache-dir              Disable the cache.
  --disable-pip-version-check

AWS CLIのインストール

上記でpipのインストールが完了したら、下記を実行します。
また、パスワードも聞かれるの再度入力してください。

sudo pip install awscli
Password:

AWS CLIのインストールの確認

以下を実行してみて

aws -h

以下のように usageが出力されればインストール完了です。

usage: aws [options] <command> <subcommand> [parameters]

設定の追加

以下を実行すると

aws configure

下記をきかれるの、順次入力していきます。

AWS Access Key ID [None]: XXXXXXXXXXXXXXXXXXXXXXXXXXX
AWS Secret Access Key [None]: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Default region name [None]: ap-northeast-1
Default output format [None]: json

AWS Access Key IDやAWS Secret Access Keyは各自に環境に合わせて入力してください。

動作確認

以下を実行して、結果がかえってくることを確認してください。

aws ec2 describe-instances

インスタンスの情報を取得

複数アカウント運用する場合

.aws/configを以下のように設定します。

[default]
output = json
region = ap-northeast-1

[profile myprj]
aws_access_key_id = XXXXXXXXXXXXXXXXXXXXXXXXXXX
aws_secret_access_key = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
region = ap-northeast-1

[profile myprj]以下を追加するアカウント情報を追記する。

動作確認

以下を実行して、結果がかえってくることを確認できれば成功です。

aws ec2 describe-instances --profile myprj 

5 件のコメント:

statistics