阅读背景:

无法创建Amazon Web Services (AWS)凭据对象

来源:互联网 

I'm trying to get started developing against the local Dynamo DB service. The first step is simply creating a client:

我正在尝试开始开发本地Dynamo DB服务。第一步是创建一个客户端:

var storedAWSCreds = new StoredProfileAWSCredentials();

This throws an exception:

这将抛出一个异常:

App.config does not contain credentials information. Either add the AWSAccessKey and AWSSecretKey or AWSProfileName

config不包含凭据信息。添加AWSAccessKey和AWSSecretKey或AWSProfileName。

My app.config has the needed properties:

我的app.config有必要的属性:

<add key="AWSProfileName" value="justin"/>
<add key="AWSProfilesLocation" value="C:\code\dynamodb\credentials"/>

The credentials profile file:

凭证概要文件:

justin
aws_access_key_id = REMOVED-FOR-POST
aws_secret_access_key = REMOVED-FOR-POST

At this point I thought I would try one of the other overloaded methods and explicitly tell the constructor what the parameters should be:

此时,我想尝试其他重载方法中的一种,并显式地告诉构造函数参数应该是什么:

var storedAWSCreds = new StoredProfileAWSCredentials("justin", @"C:\code\dynamodb\credentials");

Again, the same exception.

再次,同样的异常。

Okay, the exception says I can provide the credentials directly in my config so I tried that:

好的,例外情况是我可以直接在配置中提供凭证,所以我尝试了:

<add key="AWSAccessKey" value="REMOVED-FOR-POST"/>
<add key="AWSSecretKey" value="REMOVED-FOR-POST"/>

Again, the same exception.

再次,同样的异常。

How can I get the StoredProfileAWSCredentials object created? I'm clearly missing something obvious or their exception messages are incorrect.

如何创建StoredProfileAWSCredentials对象?我明显漏掉了一些明显的东西,或者他们的异常信息是错误的。

I will point out, I can create a BasicAWSCredentials object by specifying the access key and secret key in the constructor:

我要指出的是,我可以通过在构造函数中指定访问键和秘密键来创建BasicAWSCredentials对象:

var basicAWSCreds = new BasicAWSCredentials("REMOVED-FOR-POST", "REMOVED-FOR-POST");

But, at some point I would prefer to not have it hard-coded in my application.

但是,在某种程度上,我宁愿不把它硬编码在我的应用程序中。

2 个解决方案

#1


4  

Your config section

你的配置节

<add key="AWSProfilesLocation" value="C:\code\dynamodb\credentials" />

should be

应该是

<add key="AWSProfilesLocation" value="C:\code\dynamodb\credentials\filename.json" /> 

for it to work. In other words specify the file name in the Profile location.

为它工作。换句话说,在配置文件位置中指定文件名。

If you using newer SDK then using the following would work as well:

如果您使用更新的SDK,那么使用以下代码也可以:

<configSections>
   <section name="aws" type="Amazon.AWSSection, AWSSDK" />
</configSections>
<aws profileName="YourProfileName" profilesLocation="C:\aws\credentials\aws-credentialfile.json" region="xx-xxxx-x" />

Nachi

那智

#2


0  

The profile name needs to be in square brackets, like so

配置文件名称需要像这样在方括号中

[justin]
aws_access_key_id = REMOVED-FOR-POST
aws_secret_access_key = REMOVED-FOR-POST

分享到: