Table of Contents

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 string

The 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

string

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

string

DefaultProfileName

public const string DefaultProfileName = "default"

Field Value

string

SharedConfigFileEnvVar

public const string SharedConfigFileEnvVar = "AWS_CONFIG_FILE"

Field Value

string

SharedCredentialsFileEnvVar

public const string SharedCredentialsFileEnvVar = "AWS_SHARED_CREDENTIALS_FILE"

Field Value

string

Properties

ConfigFilePath

The path to the config file

public string ConfigFilePath { get; }

Property Value

string

DefaultConfigFilePath

The default file path for the config file. By default it searches in ~/.aws/config

public static string DefaultConfigFilePath { get; }

Property Value

string

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

string

FilePath

The path to the credentials file

public string FilePath { get; }

Property Value

string

Methods

CopyProfile(string, string)

Make a copy of the profile with fromProfileName called toProfileName.

public void CopyProfile(string fromProfileName, string toProfileName)

Parameters

fromProfileName string

The name of the profile to copy from.

toProfileName string

The 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 string

The name of the profile to copy from.

toProfileName string

The name of the new profile.

force bool

If true and the destination profile exists it will be overwritten.

ListProfileNames()

public List<string> ListProfileNames()

Returns

List<string>

ListProfiles()

public List<CredentialProfile> ListProfiles()

Returns

List<CredentialProfile>

RegisterProfile(CredentialProfile)

Add the profile given. If the profile already exists, update it.

public void RegisterProfile(CredentialProfile profile)

Parameters

profile CredentialProfile

The profile to be written.

RenameProfile(string, string)

Rename the profile with oldProfileName to newProfileName.

public void RenameProfile(string oldProfileName, string newProfileName)

Parameters

oldProfileName string

The profile to rename.

newProfileName string

The new name for the profile.

RenameProfile(string, string, bool)

Rename the profile with oldProfileName to newProfileName.

public void RenameProfile(string oldProfileName, string newProfileName, bool force)

Parameters

oldProfileName string

The profile to rename.

newProfileName string

The new name for the profile.

force bool

If true and the destination profile exists it will be overwritten.

TryGetProfile(string, out CredentialProfile)

public bool TryGetProfile(string profileName, out CredentialProfile profile)

Parameters

profileName string
profile CredentialProfile

Returns

bool

UnregisterProfile(string)

Deletes the section with the given ProfileName from the SharedCredentialsFile, if one exists.

public void UnregisterProfile(string profileName)

Parameters

profileName string

The ProfileName of the section to delete.