Reputation: 1571
I want to develop a simple app that could get AWS keys from command line and access AWS S3 service. All C# samples and AWS documentation on .Net that I have seen uses either SDK store, credential files or environment variables. Is there a way to just create AmazonS3Client and specify keys for it without creating external files or setting environment variables?
This is C# .net core 2.0. Eventually this app would run on linux and windows so platform-neutral approach would be preferable.
Upvotes: 0
Views: 3719
Reputation:
You can use the AWSAccessKey + AWSSecretKey to authenticate.
AmazonS3Client
offers a constructor accepting an object of type AWSCredentials.
AmazonS3Client(AWSCredentials)
Just pass an instance of type BasicAWSCredentials
specifying the two keys. You could get them from the arguments if needed
Source: http://docs.aws.amazon.com/sdkfornet1/latest/apidocs/html/T_Amazon_S3_AmazonS3Client.htm
Have fun,
Seb
Upvotes: 3