Skip to content

Instantly share code, notes, and snippets.

@dsect
Last active May 24, 2021 11:47
Show Gist options
  • Select an option

  • Save dsect/ee7a84fc23e8b1be8a9ee8a451ce924a to your computer and use it in GitHub Desktop.

Select an option

Save dsect/ee7a84fc23e8b1be8a9ee8a451ce924a to your computer and use it in GitHub Desktop.
.NET Amazon Creds Running Locally - from Profile
// if profiles are mfa-enabled - add AWSSDK.SecurityToken Nuget package
// otherwise - will encounter runtime error
private static IAmazonS3 GetAmazonS3()
{
if (Debugger.IsAttached)
{
var sharedFile = new SharedCredentialsFile();
sharedFile.TryGetProfile("Your Profile Name", out var profile);
AWSCredentialsFactory.TryGetAWSCredentials(profile, sharedFile, out var credentials);
return new AmazonS3Client(credentials);
}
return new AmazonS3Client();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment