AWS PowerShell来获取AWS帐号 [英] AWS Powershell to retrieve AWS account number
问题描述
有谁知道如何使用AWS PowerShell来获得AWS帐号?看起来不像有可为的API。
Does anyone know how to get AWS account number using AWS Powershell? Doesn't look like there's an API available for that.
推荐答案
不直接。但是,您的帐户ID是阿恩的一部分您创建的资源......和那些自动为您创建的。有的资源也将列出你作为一个OWNERID。
Not directly. However, your Account ID is a part of the Arn of resources that you create... and those that are automatically created for you. Some resources will also list you as an OwnerId.
的<一个href="http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-network-security.html#default-security-group"相对=nofollow>默认安全组自动为您在每个区域中创建,并且无法删除。这使得一个可靠的候选人获取我们的帐户ID。
The Default Security Group is automatically created for you in each region, and cannot be deleted. This makes it a reliable candidate for retrieving our account Id.
例如:
PS C:/> $accountId = @(get-ec2securitygroup -GroupNames "default")[0].OwnerId
PS C:/> $accountId
000011112222
这篇关于AWS PowerShell来获取AWS帐号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!