1
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 5 years have passed since last update.

AWS Account ID を知る方法

1
Posted at

はじめに

異なるAWSアカウント間でVPC Peering する場合などには接続先のAWS Account ID を指定する必要があります。しかし意外と取得する方法がわからなくて困ってたので共有します。もっと簡単に知る方法あれば教えてください。

AWS Account ID を知る方法

1. AWS マネジメントコンソールから

AWS マネジメントコンソールに入ったときにロールの選択のところでアカウント名の横のカッコに記載されている数字列がAWS Account ID です。

2. AWS CLI から

https://dev.classmethod.jp/cloud/aws/get-aws-account-id-with-get-caller-identity/ この記事で知りました。 GetCallerIdentity というのがあるらしい。

$ aws sts get-caller-identity
{
    "Account": "0123456789012",
    "UserId": "ABCD1234EFGHGELEGSL3",
    "Arn": "arn:aws:iam::012345678901234:user/ユーザ名"
}

クレデンシャルのプロフィール指定したいならこう。

$ aws sts get-caller-identity --profile mikaji
{
    "Account": "0123456789012",
    "UserId": "ABCD1234EFGHGELEGSL3",
    "Arn": "arn:aws:iam::012345678901234:user/ユーザ名"
}

おわりに

AWS CLI イイネ

1
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
1
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?