AWS CLI(コマンドラインインターフェイス)の初期設定手順を以下に示します。
目次
✅ 1. AWS CLI のインストール
Windows
公式 MSI インストーラーを使用:
https://docs.aws.amazon.com/ja_jp/cli/latest/userguide/getting-started-install.html
# インストール確認
aws --version
✅ 2. IAM ユーザーの作成(未作成の場合)
AWS マネジメントコンソールで実施:
- IAM → 「ユーザー」 → 「ユーザーを追加」
- プログラムによるアクセス にチェック
- ポリシーをアタッチ(例:
AmazonEC2FullAccess
など) - 追加完了させる。
- アクセスキーの作成をして.csvファイルをダウンロード
- アクセスキーID と シークレットアクセスキー をメモ
✅ 3. 初期設定コマンド
#基本コマンド
aws configure
#プロファイルを明示的に指定して
aws configure --profile test-user01
質問される内容:
AWS Access Key ID [None]: ← メモしたアクセスキーを入力
AWS Secret Access Key [None]: ← メモしたシークレットキーを入力
Default region name [None]: ← 例:ap-northeast-1(東京)
Default output format [None]: ← 例:json(他に text, table)
✅ 4. 設定ファイルの保存場所(Windows)
C:\Users\<ユーザー名>\.aws\config
C:\Users\<ユーザー名>\.aws\credentials
✅ 5. 設定確認
aws configure list
または
cat ~/.aws/config
cat ~/.aws/credentials
✅ 6. 動作確認
プロファイルを明示的に指定して動作確認
#確認コマンド
aws sts get-caller-identity --profile dev-user
PC:\Users\PC_User\Desktop> aws sts get-caller-identity --profile test-user01
{
"UserId": "xxxxxxxxxxxxxxxxxxx",
"Account": "xxxxxxxxxxxxxxxxxxx",
"Arn": "xxxxxxxxxxxxxxxxxxx"
}
コメント