0
0

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 1 year has passed since last update.

AWS CLIで現在のAWSアカウントIDを取得する

Posted at

記事の目的

いろんなAWSアカウントの環境をプロファイルを切り替えながら操作していて、うっかり想定外の環境を操作していたなんてことが無いように、現在操作対象となっているAWSアカウントをこのコマンドでマメに確認する

前提

AWS CLIバージョン 1.10.18 以降が使えること

コマンド

shell
aws sts get-caller-identity
実行結果の例
{
    "UserId": "XXXXXXXXXXXXXXXXXXXXXX",
    "Account": "123456789012",
    "Arn": "arn:aws:iam::123456789012:user/hoge"
}

アカウントIDのみを取得したい場合

shell
aws sts get-caller-identity --query 'Account' --output text
実行結果の例
123456789012
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?