Class StoredProfileAWSCredentials
Credentials that are retrieved using a stored profile.
Unless otherwise specified priority is given to loading credentials from the SDK credential store file which is shared between the SDK, PowerShell CLI and Toolkit. Credentials in profiles in this file are encrypted and can only be used by the user account on the current machine that stored the profile. Credentials can also be loaded from the plain-text ini-format credential file which is shared with other AWS SDKs. This file is expected to exist in a '.aws' folder in the user's home directory but alternate locations can be specified using either the AWSProfilesLocation setting in the application configuration file, or by using the AWS_SHARED_CREDENTIALS_FILE environment variable.
The profile name can be specified in the App.config using the AWSProfileName setting.
[Obsolete("This class is obsolete and will be removed in a future release. Please use Amazon.Runtime.CredentialManagement.NetSDKCredentialsFile or SharedCredentialsFile.. Visit http://docs.aws.amazon.com/sdk-for-net/v3/developer-guide/net-dg-config-creds.html for further details.")]
public class StoredProfileAWSCredentials : AWSCredentials
- Inheritance
-
StoredProfileAWSCredentials
- Inherited Members
Constructors
StoredProfileAWSCredentials()
Constructs an instance for credentials stored in a profile. This constructor searches for credentials using the account name specified using the AWSProfileName setting, if set, in the application configuration file. If the configuration file setting is not set the SDK will attempt to locate a profile with the name 'default'.
public StoredProfileAWSCredentials()
StoredProfileAWSCredentials(string)
Constructs an instance for credentials stored in a profile with the specified name. The SDK will check the SDK credential store file first before looking for the shared ini-format credentials file unless the application configuration file contains a setting for the 'AWSProfilesLocation' indicating the search should be constrained to the shared credentials file at the specified location.
public StoredProfileAWSCredentials(string profileName)
Parameters
profileName
stringThe name of the profile in which the credentials were stored.
StoredProfileAWSCredentials(string, string)
Constructs an instance for credentials stored in a profile with the specified name.
public StoredProfileAWSCredentials(string profileName, string profilesLocation)
Parameters
profileName
stringThe profile name to search for credentials for
profilesLocation
stringOptional; instructs the SDK to check for the profile in the shared credentials file at the specified location. If not set, the SDK will inspect its own credential store file first before attempting to locate a shared credential file using either the default location beneath the user's home profile folder or the location specified in the AWS_SHARED_CREDENTIALS_FILE environment variable.
Remarks
If credential materials cannot be read or are invalid due to missing data an InvalidDataException is thrown. If no credentials can be located with the specified profile name, an ArgumentException is thrown.
Properties
ProfileName
Name of the profile being used.
public string ProfileName { get; }
Property Value
ProfilesLocation
Location of the profiles, if used.
public string ProfilesLocation { get; }
Property Value
WrappedCredentials
public AWSCredentials WrappedCredentials { get; }
Property Value
Methods
CanCreateFrom(string, string)
Tests if an instance can be created from the persisted profile data. If profilesLocation is null/empty, the SDK store is searched for the profile data before probing for the profile in the shared the ini-format credential file.
public static bool CanCreateFrom(string profileName, string profilesLocation)
Parameters
profileName
stringThe name of the profile to test
profilesLocation
stringIf null/empty, the SDK store is searched for the named profile otherwise the ini-format credential file at the specified location is inspected.
Returns
- bool
True if the persisted data would yield a valid credentials instance.
GetCredentials()
Returns an instance of ImmutableCredentials for this instance
public override ImmutableCredentials GetCredentials()
Returns
IsProfileKnown(string, string)
Tests if a profile has been registered in either the SDK store or the specified credential file.
public static bool IsProfileKnown(string profileName, string profilesLocation)
Parameters
profileName
stringThe name of the profile to test
profilesLocation
stringOptional; instructs the SDK to check for the profile in the shared credentials file at the specified location. If not set, the SDK will inspect its own credential store file first before attempting to locate a shared credential file using either the default location beneath the user's home profile folder or the location specified in the AWS_SHARED_CREDENTIALS_FILE environment variable.
Returns
- bool
True if a profile with the specified name has been registered.