13

AWS Powershell を使用して AWS アカウント番号を取得する方法を知っている人はいますか? そのために利用できる API があるようには見えません。

4

4 に答える 4

0

Get-STSCallerIdentity を使用します。

私が使用するコードスニペットは次のとおりです。

    foreach ($ProfileName in $Profiles){
    if ($ProfileName -match 'gov') { 
        Initialize-AWSDefaultConfiguration -ProfileName $ProfileName -Region us-gov-east-1
        $STSCallerIdentity = Get-STSCallerIdentity
    }
    else { 
        Initialize-AWSDefaultConfiguration -ProfileName $ProfileName -Region us-east-1 
        $STSCallerIdentity = Get-STSCallerIdentity
    }
于 2019-08-20T12:27:57.207 に答える