Amazon.Runtime.AmazonServiceException: Cannot find credentials

We developed the WebService application in vs 2010 using the AWS SDK, which connects to AWS SNS.

This works great when we directly launch the VS 2010 development studio, but when we publish a web service for a local IIS or dedicated web server, it fails with the following error messages.

Amazon.Runtime.AmazonServiceException: Unable to find credentials

Exception 1 of 4:
System.ArgumentException: Path cannot be the empty string or all whitespace.
Parameter name: path
   at System.IO.Directory.GetParent(String path)
   at Amazon.Runtime.StoredProfileAWSCredentials.DetermineCredentialsFilePath(String profilesLocation)
   at Amazon.Runtime.StoredProfileAWSCredentials..ctor(String profileName, String profilesLocation)
   at Amazon.Runtime.EnvironmentAWSCredentials..ctor()
   at Amazon.Runtime.FallbackCredentialsFactory.<Reset>b__1()
   at Amazon.Runtime.FallbackCredentialsFactory.GetCredentials(Boolean fallbackToAnonymous)

Exception 2 of 4:
System.ArgumentException: Path cannot be the empty string or all whitespace.
Parameter name: path
   at System.IO.Directory.GetParent(String path)
   at Amazon.Runtime.StoredProfileAWSCredentials.DetermineCredentialsFilePath(String profilesLocation)
   at Amazon.Runtime.StoredProfileAWSCredentials..ctor(String profileName, String profilesLocation)
   at Amazon.Runtime.FallbackCredentialsFactory.<Reset>b__2()
   at Amazon.Runtime.FallbackCredentialsFactory.GetCredentials(Boolean fallbackToAnonymous)

Exception 3 of 4:
System.InvalidOperationException: The environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY were not set with AWS credentials.
   at Amazon.Runtime.EnvironmentVariablesAWSCredentials..ctor()
   at Amazon.Runtime.FallbackCredentialsFactory.<Reset>b__3()
   at Amazon.Runtime.FallbackCredentialsFactory.GetCredentials(Boolean fallbackToAnonymous)

Exception 4 of 4:
Amazon.Runtime.AmazonServiceException: Unable to reach credentials server
   at Amazon.Runtime.InstanceProfileAWSCredentials.GetContents(Uri uri)
   at Amazon.Runtime.InstanceProfileAWSCredentials.<GetAvailableRoles>d__0.MoveNext()
   at Amazon.Runtime.InstanceProfileAWSCredentials.GetFirstRole()
   at Amazon.Runtime.FallbackCredentialsFactory.<Reset>b__4()
   at Amazon.Runtime.FallbackCredentialsFactory.GetCredentials(Boolean fallbackToAnonymous)
   at Amazon.Runtime.FallbackCredentialsFactory.GetCredentials(Boolean fallbackToAnonymous)
   at Amazon.SimpleNotificationService.AmazonSimpleNotificationServiceClient..ctor()
   at CellicaAwsSnsService..ctor()
   at Service..ctor()
+4
source share
2 answers

Create a credential file on any path where you can access this path from the web service application Ex. C: \ awsfile \ Credentials but remember, don’t give any extension to this file. The file should contain the following data.

[default]
aws_access_key_id=[your_access_key]
aws_secret_access_key=[your_secret_key]

appsetting Web.config:

<appSettings>
<add key="AWSProfilesLocation" value="C:\awsfile\credentials" />
<add key="AWSRegion" value="us-east-1" />
</appSettings>
+10

AWS Explorer Visual Studio , AWS, , AWS Explorer. Windows, - , . , , .

, default.

- , IIS , , , AWS.

, AWS (. http://docs.aws.amazon.com/sdk-for-net/v2/developer-guide/net-dg-config-creds.html). web.config. , C:\aws\credentials, profile2 , web.config.

<configuration>

  <configSections>
    <section name="aws" type="Amazon.AWSSection, AWSSDK.Core" />
  </configSections>

  <aws 
    region="us-east-1" 
    profileName="profile2"
    profilesLocation="C:\aws\credentials" />

</configuration>

:

[profile1]
aws_access_key_id = {accessKey}
aws_secret_access_key = {secretKey}

[profile2]
aws_access_key_id = {accessKey}
aws_secret_access_key = {secretKey}

, AWS IAM https://console.aws.amazon.com/iam/home?region=us-east-1#/users , , , " " " ".

+1

All Articles