2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AWS-CLIのコマンド

Last updated at Posted at 2018-12-17

概要

コマンドをすぐ忘れるのでメモっておく。
( また、覚えたコマンドを随時追加していく )

ヘルプ

下記コマンドにてヘルプを確認できるようです。

ターミナル
$ aws help

EC2のコマンドについてなどは、下記のように更に階層を深くしてhelpを実行する。

ターミナル
$ aws ec2 help

基本設定

awscliの環境設定を操作するコマンド。

設定の登録

デフォルト設定を登録する。

ターミナル
# デフォルト設定
$ aws configure

プロファイルを指定して設定を登録する (ex: hoge)

ターミナル
$ aws configure --profile hoge

設定の確認

デフォルト設定の確認する。

ターミナル
$ aws configure list

プロファイル指定して確認する (ex: hoge)

ターミナル
$ aws configure list --profile hoge

Amazon S3

Amazon Simple Storage Serviceについてのコマンド

内容確認

中身を確認してみる。

ターミナル
$ aws s3 ls

# バケットを指定する場合
$ aws s3 ls s3://{$my-bucket}

アップロード

指定のフォルダ($my-folder)にアップロードする。
※ 例は、並列オプション(--recursive)を指定している

ターミナル
$ aws s3 cp myfolder s3://{$my-bucket}/{$my-folder} --recursive

ダウンロード

データをローカルにダウンロードする。
※ 例は、ログファイルを除外するようにオプション指定している

ターミナル
$ $ aws s3 sync myfolder s3://{$my-bucket}/{$my-folder} --exclude *.log

Amazon EC2

Amazon Elastic Compute Cloudについてのコマンド

インスタンスの確認(一覧)

項目を絞り込むときは、jqコマンドを利用しています。

ターミナル
$ aws ec2 describe-instances

# 表示項目絞り込み (インスタンスIDのみ)
$ aws ec2 describe-instances | jq '.Reservations[].Instances[].InstanceId'
"i-0023**************"

# 表示項目絞り込み (インスタンスID + インスタンスタイプ + プライベートIP)
$ aws ec2 describe-instances | jq '.Reservations[].Instances[] | {InstanceId, InstanceType, PrivateIpAddress}'
{
  "InstanceId": "i-0023**************",
  "InstanceType": "t2.micro",
  "PrivateIpAddress": "172.0.30.11"
}

インスタンスの確認(詳細)

ターミナル
$ aws ec2 describe-instances --instance-ids {インスタンスID}

セキュリティグループを確認

ターミナル
# デフォルト
$ aws ec2 describe-security-groups

# 表示項目絞り込み (グループ名 + 説明 + グループID + VpcID)
$ aws ec2 describe-security-groups | jq '.SecurityGroups[] | {GroupName,Description,GroupId,VpcId}'

参考サイト

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?