Class SharedCredentialsFile
- Namespace
- Amazon.Runtime.CredentialManagement
- Assembly
- AWSSDK.Core.dll
Provides access to read and write to the shared credentials INI file. The file is read, parsed, and validated at construction time. Changes can be made using the RegisterProfile() and UnregisterProfile() methods.
This class is not threadsafe.
public class SharedCredentialsFile : ICredentialProfileStore, ICredentialProfileSource
- Inheritance
-
SharedCredentialsFile
- Implements
- Inherited Members
Constructors
SharedCredentialsFile()
Construct a new SharedCredentialsFile in the default location.
public SharedCredentialsFile()
SharedCredentialsFile(string)
Construct a new SharedCredentialsFile.
public SharedCredentialsFile(string filePath)
Parameters
filePath
stringThe path of the shared credentials file.
Fields
DefaultConfigDirectory
The default directory for the config file. By default it searches in ~/.aws This behavior can be overriden.
public static readonly string DefaultConfigDirectory
Field Value
DefaultDirectory
The default directory for the credentials file. By default it searches in ~/.aws. This behavior can be overridden.
public static readonly string DefaultDirectory
Field Value
DefaultProfileName
public const string DefaultProfileName = "default"
Field Value
SharedConfigFileEnvVar
public const string SharedConfigFileEnvVar = "AWS_CONFIG_FILE"
Field Value
SharedCredentialsFileEnvVar
public const string SharedCredentialsFileEnvVar = "AWS_SHARED_CREDENTIALS_FILE"
Field Value
Properties
ConfigFilePath
The path to the config file
public string ConfigFilePath { get; }
Property Value
DefaultConfigFilePath
The default file path for the config file. By default it searches in ~/.aws/config
public static string DefaultConfigFilePath { get; }
Property Value
DefaultFilePath
The default file path for the credentials file. By default it searches for ~/.aws/credentials. This behavior can be overriden.
public static string DefaultFilePath { get; }
Property Value
FilePath
The path to the credentials file
public string FilePath { get; }
Property Value
Methods
CopyProfile(string, string)
Make a copy of the profile with fromProfileName called toProfileName.
public void CopyProfile(string fromProfileName, string toProfileName)
Parameters
fromProfileName
stringThe name of the profile to copy from.
toProfileName
stringThe name of the new profile.
CopyProfile(string, string, bool)
Make a copy of the profile with fromProfileName called toProfileName.
public void CopyProfile(string fromProfileName, string toProfileName, bool force)
Parameters
fromProfileName
stringThe name of the profile to copy from.
toProfileName
stringThe name of the new profile.
force
boolIf true and the destination profile exists it will be overwritten.
ListProfileNames()
public List<string> ListProfileNames()
Returns
ListProfiles()
public List<CredentialProfile> ListProfiles()
Returns
RegisterProfile(CredentialProfile)
Add the profile given. If the profile already exists, update it.
public void RegisterProfile(CredentialProfile profile)
Parameters
profile
CredentialProfileThe profile to be written.
RenameProfile(string, string)
Rename the profile with oldProfileName to newProfileName.
public void RenameProfile(string oldProfileName, string newProfileName)
Parameters
RenameProfile(string, string, bool)
Rename the profile with oldProfileName to newProfileName.
public void RenameProfile(string oldProfileName, string newProfileName, bool force)
Parameters
oldProfileName
stringThe profile to rename.
newProfileName
stringThe new name for the profile.
force
boolIf true and the destination profile exists it will be overwritten.
TryGetProfile(string, out CredentialProfile)
public bool TryGetProfile(string profileName, out CredentialProfile profile)
Parameters
profileName
stringprofile
CredentialProfile
Returns
UnregisterProfile(string)
Deletes the section with the given ProfileName from the SharedCredentialsFile, if one exists.
public void UnregisterProfile(string profileName)
Parameters
profileName
stringThe ProfileName of the section to delete.