public static async Task <Credentials> GetTemporaryCredentials(string credentialProfileName, string tokenProfileName, AwsAccount account) { var credentials = GetAWSCredentials(credentialProfileName); var token = GetMFAToken(tokenProfileName); var roleArn = $"arn:aws:iam::{account.AccountNumber}:role/{account.Role}"; var client = new AmazonSecurityTokenServiceClient(credentials); var request = new AssumeRoleRequest { DurationSeconds = 3600, RoleArn = roleArn, RoleSessionName = Guid.NewGuid().ToString(), SerialNumber = token.SerialNumber, TokenCode = token.TokenCode }; var response = await client.AssumeRoleAsync(request); return(response.Credentials); }
public AwsConsole(string credentialProfileName, string tokenProfileName, AwsAccount account) { _credentialProfileName = credentialProfileName; _tokenProfileName = tokenProfileName; _account = account; }