User guide

Although you can reference a profile programmatically by using
Amazon.Runtime.StoredProfileAWSCredentials, we recommend that you use the aws element
instead. The following example references a profile named development and uses it to create an
AmazonS3Client object.
AWSCredentials credentials = new StoredProfileAWSCredentials("development");
IAmazonS3 s3Client = new AmazonS3Client(credentials, RegionEndpoint.USWest2);
Tip
If you want to use the default profile, omit the AWSCredentials object, and the SDK for .NET
will automatically use your default credentials to create the client object.
Specifying Roles or Temporary Credentials
For applications that run on Amazon EC2 instances, the most secure way to manage credentials is to
use IAM roles for EC2 Instances. See the following topic for more information.
Using IAM Roles for EC2 Instances with the SDK for .NET (p. 108)
For application scenarios in which the software executable will be available to users outside your
organization, we recommend that you design the software to use temporary security credentials. In
addition to providing restricted access to AWS resources, these credentials have the benefit of expiring
after a specified period of time. For more information about temporary security credentials, go to:
Using Security Tokens to Grant Temporary Access to Your AWS Resources
Authenticating Users of AWS Mobile Applications with a Token Vending Machine.
Although the title of the second article above refers specifically to mobile applications, the article itself
contains information that is useful for any AWS application that is deployed outside of your organization.
Using Proxy Credentials
If your software communicates with AWS through a proxy, you could specify credentials for the proxy
using the ProxyCredentials property on the ClientConfig class for the service. For example, for Amazon
S3, you could use code similar to the following, where my-username and my-password are the proxy
username and password specified in a NetworkCredential object.
AmazonS3Config config = new AmazonS3Config();
config.ProxyCredentials = new NetworkCredential("my-username", "my-password");
Earlier versions of the SDK used ProxyUsername and ProxyPassword, but these properties have been
deprecated.
AWS Region Selection
AWS regions allow you to access AWS services that reside physically in a specific geographic region.
This can be useful both for redundancy and to keep your data and applications running close to where
you and your users will access them. To select a particular region, configure the AWS client object with
an endpoint that corresponds to that region.
For example:
Version v2.0.0
13
AWS SDK for .NET Developer Guide
AWS Region Selection