0
0

More than 3 years have passed since last update.

awscliの導入と認証キーの登録

Posted at

概要

AWSで開発をするにあたりaws-cliというものがあるとのことで導入してみる

install

brewでaws-cliをインストールする

$ brew install awscli

$ aws --version
aws-cli/2.2.31 Python/3.9.6 Darwin/20.5.0 source/x86_64 prompt/off

認証キーを導入する

過去の記事ではIAMユーザーの認証キーを記載したファイルを直打ちで作成したが、aws-cliのコマンドでも作成が可能とのことで作成する

$ aws configure
AWS Access Key ID [None]: XXXXXXXXXXXXXXXXXXXX
AWS Secret Access Key [None]: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Default region name [None]: ap-northeast-1
Default output format [None]: json

上記実行すると~/.aws配下に下記のファイルが作成される

$ cat ~/.aws/credentials
[default]
aws_access_key_id = XXXXXXXXXXXXXXXXXXXX
aws_secret_access_key = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

$ cat ~/.aws/config
[default]
region = ap-northeast-1
output = json

これでterraformでの環境構築も引き続き問題なく行える

aws-cliのコマンドを実行してみる

一例としてec2の一覧を出すコマンド
現状ec2は1つも起動していなかったためこのような結果に

$ aws ec2 describe-instances
{
    "Reservations": []
}

検証として東京リージョンでec2インスタンス(Name: test-server)を作成すると

aws ec2 describe-instances --query "Reservations[].Instances[].Tags[]"
[
    {
        "Key": "Name",
        "Value": "test-server"
    }
]

一覧取得ができた

0
0
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
0
0