10
10

More than 1 year has passed since last update.

aws-cli の簡単な使い方

Last updated at Posted at 2019-01-06

aws-cli の設定を変更した際にちゃんと動くかざっと確認する方法です。

aws-cli のインストール

Arch Linux

sudo pacman -S aws-cli-v2

Ubuntu 21.10

wget https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip
unzip awscli-exe-linux-x86_64.zip
sudo aws/install

設定は、次のファイルで変更します。

.aws/config
.aws/credentials

.aws/config
[default]
output = json
region = ap-northeast-1
.aws/credentials
[default]
aws_access_key_id = AKIAICUGUJTHE2AAAAAB
aws_secret_access_key = JdJTvIFukHeGO4kNWYez111111111111

バージョンの確認

$ aws --version
aws-cli/2.7.35 Python/3.9.11 Linux/5.15.0-48-generic exe/x86_64.ubuntu.22 prompt/off

ログインユーザーの確認

$ aws sts get-caller-identity
{
    "UserId": "AIDAIHEWDBIJGJOGUABCD",
    "Account": "153035299999",
    "Arn": "arn:aws:iam::153035299999:user/somebody"
}

有効でないと次のようになります。

$ aws sts get-caller-identity

An error occurred (InvalidClientTokenId) when calling the GetCallerIdentity operation: The security token included in the request is invalid.

AWS のユーザーの確認

aws iam list-users

特定のユーザーの確認

aws iam get-user --user-name scott

AWS のグループの確認

aws iam list-groups

AWS のグループの確認 (コンパクト)

aws iam list-groups --query 'Groups[].GroupName'

EC2 のインスタンスの確認

aws ec2 describe-instances | jq '.Reservations[].Instances[].InstanceId'

EC2 のインスタンスの確認 (IP アドレス)

aws ec2 describe-instances | jq '.Reservations[].Instances[].PublicIpAddress'
10
10
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
10
10