Search code examples
c#amazon-web-services.net-coreaws-toolkit

AWS .NET - Difference between SharedCredentialsFile and NetSDKCredentialsFile


I was following the AWS tutorials for .NET developers and found out that it features the usage of both SharedCredentialsFile and NetSDKCredentialsFile. Is there any difference between those two APIs? In my code, they can be interchanged without any apparent difference:

    public CredentialProfile GetProfile(string profileName)
    {
        // Which one should I use?
        var sharedFile = new SharedCredentialsFile();
        //var sharedFile = new NetSDKCredentialsFile();

        if (!sharedFile.TryGetProfile(profileName, out var result))
        {
            var options = new CredentialProfileOptions
            {
                AccessKey = Configuration.AccessKey,
                SecretKey = Configuration.SecretKey
            };

            var profile = new CredentialProfile(profileName, options);
            profile.Region = RegionEndpoint.EUWest1;
            sharedFile .RegisterProfile(profile);

            result = profile;
        }

        return result;
    }

Is one of them obsolete? Is there a best practice to which one should be used? Or are they identical?

Note, that I am developing on a Windows PC, but the app will run on a Linux server. Could this make any difference?


Solution

  • The AWS Toolkit for Visual Studio integrates with both NetSDKCredentialsFile and SharedCredentialsFile. NetSDKCredentialsFile was the original credential store for the .NET SDK before AWS SDKs unified around the .aws/credentials file which SharedCredentialsFile manages. At this point I would recommend using SharedCredentialsFile so your credentials will be compatible with all of the other AWS tools and SDKs.