サンプル集  >  other  >  AWS CLI② profileの作成と確認
AWS CLI② profileの作成と確認
2025/12/20

AWS CLIのprofileの作成と確認をします。

◆環境
OS Windows 11 Home 25H2
aws-cli 2.28.6

コマンドプロンプトでaws cliを使って確認します。

aws sts get-caller-identity
aws configure list
aws configure list --profile dev-ym
aws configure list-profiles
aws configure --profile dev-ym

今CLIが指しているAWSアカウントID/ユーザーを確認します。

> aws sts get-caller-identity
{
    "UserId": "*****************DBS3",
    "Account": "8**********8",
    "Arn": "arn:aws:iam::8**********8:user/ymlibop1"
}

どんな設定値になっているか確認します。

> aws configure list
      Name                  Value             Type    Location
      ----                  -----             ----    --------
   profile                           None    None
access_key   ****************SZRM shared-credentials-file
secret_key   ****************s4WY shared-credentials-file
    region         ap-northeast-1      config-file    ~/.aws/config

プロファイルを作成します。

> aws configure --profile dev-ym
AWS Access Key ID [None]: ****************M73K
AWS Secret Access Key [None]: **********************************/hGy
Default region name [None]: ap-northeast-1
Default output format [None]:

プロファイルの一覧を表示する。

> aws configure list-profiles
default
dev-ym

プロファイルを指定して内容を確認してみます。

> aws configure list --profile dev-ym
      Name                  Value             Type    Location
      ----                  -----             ----    --------
   profile                 dev-ym           manual    --profile
access_key   ****************M73K shared-credentials-file
secret_key   ****************/hGy shared-credentials-file
    region         ap-northeast-1      config-file    ~/.aws/config

実際の設定はC:\Users\ymlib\.aws配下のconfigファイルとcredentialsファイルに保存されていました。

~\.aws\config
[default]
region = ap-northeast-1

[profile dev-ym]
region = ap-northeast-1

~\.aws\credentials
[default] aws_access_key_id = ****************SZRM
aws_secret_access_key = ************************************s4WY

[dev-ym]
aws_access_key_id = ****************M73K
aws_secret_access_key = ************************************/hGy

関連項目

AWS CLIインストール
AWSアクセスキー

▲ PageTop  ■ Home


Copyright (C) 2025 ymlib.com