AWS Profile的{Visual Studio Desktop应用程序

时间:2015-06-03 18:03:57

标签: visual-studio visual-studio-2012 amazon-web-services amazon-s3

我在DEV中工作得很好。我可以将图像上传到S3 for AWS。它是一个桌面应用程序,它使用我在Visual Studio中的AWS浏览器中设置的AWS配置文件(我称之为配置文件“生产”)。再次,这很好。我的App.config有这一行。

<add key="AWSProfileName" value="production" />

Wen我将应用程序放在生产机器上,我收到了凭据错误。为什么不在生产机器上看到我的凭据?我发布申请时不应该过来吗?如何将配置文件信息投入生产?谢谢。

Amazon.Runtime.AmazonServiceException: Unable to find credentials 

Exception 1 of 4: 
System.ArgumentException: App.config does not contain credentials information. Either add the AWSAccessKey and AWSSecretKey or AWSProfileName. 
 at Amazon.Runtime.StoredProfileAWSCredentials..ctor(String profileName, String profilesLocation) 
 at Amazon.Runtime.EnvironmentAWSCredentials..ctor() 
 at Amazon.Runtime.FallbackCredentialsFactory.b__1() 
 at Amazon.Runtime.FallbackCredentialsFactory.GetCredentials(Boolean fallbackToAnonymous) 

Exception 2 of 4: 
System.ArgumentException: App.config does not contain credentials information. Either add the AWSAccessKey and AWSSecretKey or AWSProfileName. 
 at Amazon.Runtime.StoredProfileAWSCredentials..ctor(String profileName, String profilesLocation) 
 at Amazon.Runtime.FallbackCredentialsFactory.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.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.d__0.MoveNext() 
 at Amazon.Runtime.InstanceProfileAWSCredentials.GetFirstRole() 
 at Amazon.Runtime.FallbackCredentialsFactory.b__4() 
 at Amazon.Runtime.FallbackCredentialsFactory.GetCredentials(Boolean fallbackToAnonymous) 


 at Amazon.Runtime.FallbackCredentialsFactory.GetCredentials(Boolean fallbackToAnonymous) 
 at Amazon.S3.AmazonS3Client..ctor(RegionEndpoint region) 
 at SRC_XRay_Sync_Application.MainWindow.startUpload()

1 个答案:

答案 0 :(得分:0)

NET SDK Store中的配置文件是每个用户/计算机。引用文档:

  

SDK Store中的凭据是加密的,SDK Store是   在用户的主目录中,这可以限制意外的风险   公开你的证书。

在您的生产计算机上,您应该以相同的方式创建配置文件,或者因为您不太可能在这样的计算机上安装Visual Studio,而是使用适用于Windows PowerShell的AWS工具。

如果不担心安全性,您可以将凭证文件直接放在用户的主目录中,也可以指定凭证文件的位置。当然,不建议这样做,因为您将AWS的秘密暴露给可能的妥协。

<configuration>
  <configSections>
    <section name="aws" type="Amazon.AWSSection, AWSSDK.Core"/>
  </configSections>
  <aws profileName="production" profilesLocation="C:\aws_service_credentials\mycredentials"/>
</configuration>

最后,如果生产机器在EC2中,我认为使用临时凭证,实例配置文件和IAM角色会更好。这避免了尝试将凭证安全地放到机器上的麻烦。