Macでのaws cliのインストールメモ
Macでのaws cliのインストールメモ
Macにaws-cliをインストールしたのでそのメモ。インストールした環境はOS X 10.10.2(14C109)。
pipのインストール
pipというものを入れます。pipはPythonで書かれたパッケージソフトウェアをインストール・管理するためのパッケージ管理システム。
pipインストール
$ sudo easy_install pip Password: Searching for pip Reading https://pypi.python.org/simple/pip/ Best match: pip 6.0.7 Downloading https://pypi.python.org/packages/source/p/pip/pip-6.0.7.tar.gz#md5=26fa8f4c0f9a78c6c96ccfbcf34f5c31 Processing pip-6.0.7.tar.gz Writing /tmp/easy_install-2qiSoK/pip-6.0.7/setup.cfg Running pip-6.0.7/setup.py -q bdist_egg --dist-dir /tmp/easy_install-2qiSoK/pip-6.0.7/egg-dist-tmp-0T5Qcz warning: no previously-included files found matching '.coveragerc' warning: no previously-included files found matching '.mailmap' warning: no previously-included files found matching '.travis.yml' warning: no previously-included files found matching 'pip/_vendor/Makefile' warning: no previously-included files found matching 'tox.ini' warning: no previously-included files found matching 'dev-requirements.txt' no previously-included directories found matching '.travis' no previously-included directories found matching 'docs/_build' no previously-included directories found matching 'contrib' no previously-included directories found matching 'tasks' no previously-included directories found matching 'tests' Adding pip 6.0.7 to easy-install.pth file Installing pip script to /usr/local/bin Installing pip2.7 script to /usr/local/bin Installing pip2 script to /usr/local/bin Installed /Library/Python/2.7/site-packages/pip-6.0.7-py2.7.egg Processing dependencies for pip Finished processing dependencies for pip
インストールできたか確認
$ which pip /usr/local/bin/pip $ pip --version pip 6.0.7 from /Library/Python/2.7/site-packages/pip-6.0.7-py2.7.egg (python 2.7)
awscliのインストール
pipを使ってawscliをインストール
pipを使って目的のawscliをインストールします。
$ sudo pip install awscli The directory '/Users/kasshy/Library/Logs/pip' or its parent directory is not owned by the current user and the debug log has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want the -H flag. The directory '/Users/kasshy/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want the -H flag. The directory '/Users/kasshy/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want the -H flag. Collecting awscli Downloading awscli-1.7.4.tar.gz (288kB) 100% |################################| 290kB 455kB/s Collecting botocore<0.86.0,>=0.85.0 (from awscli) Downloading botocore-0.85.0.tar.gz (1.3MB) 100% |################################| 1.3MB 161kB/s Collecting bcdoc<0.13.0,>=0.12.0 (from awscli) Downloading bcdoc-0.12.2.tar.gz Collecting colorama==0.2.5 (from awscli) Downloading colorama-0.2.5.tar.gz Collecting docutils>=0.10 (from awscli) Downloading docutils-0.12.tar.gz (1.6MB) 100% |################################| 1.6MB 178kB/s Collecting rsa==3.1.2 (from awscli) Downloading rsa-3.1.2.tar.gz Collecting jmespath==0.5.0 (from botocore<0.86.0,>=0.85.0->awscli) Downloading jmespath-0.5.0.tar.gz Collecting python-dateutil<3.0.0,>=2.1 (from botocore<0.86.0,>=0.85.0->awscli) Downloading python_dateutil-2.4.0-py2.py3-none-any.whl (175kB) 100% |################################| 176kB 289kB/s Requirement already satisfied (use --upgrade to upgrade): six>=1.1.0 in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from bcdoc<0.13.0,>=0.12.0->awscli) Collecting pyasn1>=0.1.3 (from rsa==3.1.2->awscli) Downloading pyasn1-0.1.7.tar.gz (68kB) 100% |################################| 69kB 630kB/s Installing collected packages: pyasn1, python-dateutil, jmespath, rsa, docutils, colorama, bcdoc, botocore, awscli Running setup.py install for pyasn1 Found existing installation: python-dateutil 1.5 Uninstalling python-dateutil-1.5: Successfully uninstalled python-dateutil-1.5 Running setup.py install for jmespath changing mode of build/scripts-2.7/jp from 644 to 755 changing mode of /usr/local/bin/jp to 755 Running setup.py install for rsa Installing pyrsa-encrypt-bigfile script to /usr/local/bin Installing pyrsa-encrypt script to /usr/local/bin Installing pyrsa-verify script to /usr/local/bin Installing pyrsa-sign script to /usr/local/bin Installing pyrsa-priv2pub script to /usr/local/bin Installing pyrsa-decrypt script to /usr/local/bin Installing pyrsa-keygen script to /usr/local/bin Installing pyrsa-decrypt-bigfile script to /usr/local/bin Running setup.py install for docutils changing mode of build/scripts-2.7/rst2html.py from 644 to 755 changing mode of build/scripts-2.7/rst2s5.py from 644 to 755 changing mode of build/scripts-2.7/rst2latex.py from 644 to 755 changing mode of build/scripts-2.7/rst2xetex.py from 644 to 755 changing mode of build/scripts-2.7/rst2man.py from 644 to 755 changing mode of build/scripts-2.7/rst2xml.py from 644 to 755 changing mode of build/scripts-2.7/rst2pseudoxml.py from 644 to 755 changing mode of build/scripts-2.7/rstpep2html.py from 644 to 755 changing mode of build/scripts-2.7/rst2odt.py from 644 to 755 changing mode of build/scripts-2.7/rst2odt_prepstyles.py from 644 to 755 changing mode of /usr/local/bin/rst2html.py to 755 changing mode of /usr/local/bin/rst2latex.py to 755 changing mode of /usr/local/bin/rst2man.py to 755 changing mode of /usr/local/bin/rst2odt.py to 755 changing mode of /usr/local/bin/rst2odt_prepstyles.py to 755 changing mode of /usr/local/bin/rst2pseudoxml.py to 755 changing mode of /usr/local/bin/rst2s5.py to 755 changing mode of /usr/local/bin/rst2xetex.py to 755 changing mode of /usr/local/bin/rst2xml.py to 755 changing mode of /usr/local/bin/rstpep2html.py to 755 Running setup.py install for colorama Running setup.py install for bcdoc Running setup.py install for botocore Running setup.py install for awscli changing mode of build/scripts-2.7/aws from 644 to 755 changing mode of build/scripts-2.7/aws.cmd from 644 to 755 changing mode of build/scripts-2.7/aws_completer from 644 to 755 changing mode of build/scripts-2.7/aws_zsh_completer.sh from 644 to 755 changing mode of /usr/local/bin/aws to 755 changing mode of /usr/local/bin/aws.cmd to 755 changing mode of /usr/local/bin/aws_completer to 755 changing mode of /usr/local/bin/aws_zsh_completer.sh to 755 Successfully installed awscli-1.7.4 bcdoc-0.12.2 botocore-0.85.0 colorama-0.2.5 docutils-0.12 jmespath-0.5.0 pyasn1-0.1.7 python-dateutil-2.4.0 rsa-3.1.2
インストールできたか確認
$ which aws /usr/local/bin/aws $ aws --v aws-cli/1.7.4 Python/2.7.6 Darwin/14.1.0
IAMの作成とawscliのコンフィグレーション
awscliでAWSリソースの参照・操作をするために必要な情報を設定します。
IAMユーザの作成
AWSのコンソール等でIAMユーザを作成します。 Access Key、Secret Access Keyなどを確認しておきます。
アクセスキーの設定
$ aws configure AWS Access Key ID [None]: XXXXXXXX AWS Secret Access Key [None]: XXXXXXXX Default region name [None]: ap-northeast-1 Default output format [None]: text
設定の確認方法
$ ls -la ~/.aws total 16 drwxr-xr-x 4 kasshy staff 136 2 4 17:05 . drwxr-xr-x+ 63 kasshy staff 2142 2 4 17:05 .. -rw------- 1 kasshy staff 48 2 4 17:05 config -rw------- 1 kasshy staff 116 2 4 17:05 credentials $ cat ~/.aws/config [default] output = text region = ap-northeast-1
実際にコマンドをうってみる
$ aws s3 ls A client error (AccessDenied) occurred when calling the ListBuckets operation: Access Denied
あ、IAMに権限がついていませんでした。AWSのコンソール等でIAMユーザーに権限を付与します。
$ aws s3 ls 2014-12-11 15:41:53 XXXXX
S3にあるバケット名の一覧が表示されれば成功です。
コマンドの入力補完も設定しておく
$ echo "complete -C aws_completer aws" >> ~/.bash_profile $ source ~/.bash_profile
awsとうってからタブを打つとコマンド候補が表示されます。
$ aws autoscaling cognito-sync ecs importexport route53 sts cloudformation configservice elasticache kinesis route53domains support cloudhsm configure elasticbeanstalk kms s3 swf cloudsearch datapipeline elastictranscoder lambda s3api cloudsearchdomain deploy elb logs ses cloudtrail directconnect emr opsworks sns cloudwatch dynamodb glacier rds sqs cognito-identity ec2 iam redshift storagegateway