- 追加された行はこの色です。
- 削除された行はこの色です。
// 下階層用テンプレート
#topicpath
----
//ここにコンテンツを記述します。
#contents
AWS CLIとは、AWSのCommand Line Interface つまりターミナルからAWSを操作するためのツール群です。
-[[AWS コマンドラインインターフェイス | AWS>https://aws.amazon.com/jp/cli/]]
$ aws s3 ls s3://nu.mine.kino.hogebucket
2016-11-10 12:46:26 700 hoge2.py
とかやってS3をターミナルから操作することが出来ます。便利です。。
**インストール [#z4c0879d]
あちなみにMacでやっててOSは El Capitanです
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.11.6
BuildVersion: 15G1108
$ sudo easy_install pip
$ sudo pip install awscli --upgrade --ignore-installed six
$ sudo pip install boto3 --upgrade --ignore-installed six
$ sudo aws --v
$ which aws
どうもこのignoreオプションをつけないとエラーが出たっぽい、、。
**環境設定 [#bb785c5d]
クライアントにcredential情報を設定するためのコマンドを実行します。
AWS Access Key ID、AWS Secret Access Keyはマネジメントコンソールであらかじめ設定済みと仮定します。
参考
[[Amazon S3 再入門 – AWS IAMでアクセスしてみよう!>https://cloudpack.media/5726]]
$ aws configure
AWS Access Key ID [****************]: xxxxxxxxxxxxxx ←あらかじめマネジメントコンソールで設定済みの値。
AWS Secret Access Key [****************]: yyyyyyyyyy ←あらかじめマネジメントコンソールで設定済みの値。
Default region name [None]: ap-northeast-1 ← 東京
Default output format [None]: json
$
$ ls -lrt ~/.aws/
-rw-r--r-- 1 masatomix staff 118 11 10 12:41 credentials
-rw------- 1 masatomix staff 48 11 10 12:41 config
$ cat ~/.aws/config
[default]
output = json
region = ap-northeast-1
$ cat ~/.aws/credentials
[default]
aws_access_key_id = xxxxxxxxxxxxxx
aws_secret_access_key = yyyyyyyyyy
インストール完了です。コマンドラインからAWSが操作できるようになりました。
**つかってみる。 [#tdfacf3e]
$ aws s3 ls ← Bucketの一覧表示
2016-11-08 18:59:46 nu.mine.kino.hogebucket
$ aws s3 ls s3://nu.mine.kino.hogebucket --recursive ← 指定したBucketの中身を表示
$ ls -lrt dir1
total 8
-rw-r--r-- 1 masatomix staff 13 11 12 10:31 file1.txt
$ aws s3 sync dir1 s3://nu.mine.kino.hogebucket/dir2
upload: dir1/file1.txt to s3://nu.mine.kino.hogebucket/dir2/file1.txt ローカルのdir1ディレクトリと、Bucketのdir2ディレクトリを同期。
$ aws s3 ls s3://nu.mine.kino.hogebucket/ --recursive
2016-11-12 10:33:26 13 dir2/file1.txt
**関連リンク [#h5cb69ca]
-[[【初心者向け】MacユーザがAWS CLIを最速で試す方法 | Developers.IO>http://dev.classmethod.jp/cloud/aws/mac-aws-cli/]] 参考になりました!
-[[Amazon S3 再入門 – AWS IAMでアクセスしてみよう!>https://cloudpack.media/5726]] IAMに権限をつける件。
-[[AWS CLIのS3コマンドまとめ - TASK NOTES>http://www.task-notes.com/entry/20150904/1441335600]]
----
この記事は
#vote(おもしろかった,そうでもない)
- Raspberry Piでやる場合はpipをpip3と読み替えればPython3系にインストールされるようです -- [[きの]] &new{2016-11-12 (土) 17:12:07};
#comment
#topicpath
SIZE(10){現在のアクセス:&counter;}