Programmatically get your AWS Account ID with .NET
Here is a quick way to get your AWS Account ID with .NET
First, add the AWSSDK.SecurityToken
package to your project.
Then it’s just a few lines of code -
using Amazon.SecurityToken;
AmazonSecurityTokenServiceClient client = new AmazonSecurityTokenServiceClient();
var response = await client.GetCallerIdentityAsync(new Amazon.SecurityToken.Model.GetCallerIdentityRequest());
Console.WriteLine(response.Account);
Hope this saves someone a few hours!