Last active
May 24, 2021 11:47
-
-
Save dsect/ee7a84fc23e8b1be8a9ee8a451ce924a to your computer and use it in GitHub Desktop.
.NET Amazon Creds Running Locally - from Profile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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