问题描述
我正在使用带有Cognito的AWS DynamoDB来授权来自Android的访问权限(到目前为止是未经授权的用户)。
我的数据库位于 eu-central-1
中,我使用 com.amazonaws:aws-android-sdk-ddb:2.2.8
,例如:
I'm using AWS DynamoDB with Cognito to authorize access (unauthorized user so far) from Android.My db is in eu-central-1
and I use com.amazonaws:aws-android-sdk-ddb:2.2.8
, as:
CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(context,
"eu-central-1:XXX",
Regions.EU_CENTRAL_1
);
AmazonDynamoDBClient ddbClient = new AmazonDynamoDBClient(credentialsProvider);
final DynamoDBMapper mapper = new DynamoDBMapper(ddbClient);
在日志中,我看到:
但是当我尝试获取数据时,我会得到:
However when I try to fetch data I get:
似乎连接到us-east-1,而不是指定的欧盟之一。角色有权访问适当的数据库资源(欧盟专用),并且在美国东部没有dynamoDB。
It seems to connecting to us-east-1 instead of specified EU one. Role has access to proper db resource (EU one), and there is no dynamoDB in US-east. Any ideas where I should specify eu region and I missed it?
推荐答案
哦,所以正确的方法是:
Oh, so proper way is:
ddbClient.setRegion(Region.getRegion(Regions.EU_CENTRAL_1));
这篇关于使用DynamoDB进行Cognito-连接到us-east-1而不是eu-central-1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!