使用DynamoDB进行Cognito-连接到us-east-1而不是eu-central-1 [英] Cognito with DynamoDB - connecting to us-east-1 instead eu-central-1

查看:137
本文介绍了使用DynamoDB进行Cognito-连接到us-east-1而不是eu-central-1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有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);

在日志中,我看到:


AmazonWebServiceClient:在区域元数据中未找到{cognito-identity,eu-central-1}
,尝试使用该区域的标准
模式构建端点:'cognito- identity.eu-central-1.amazonaws.com'

AmazonWebServiceClient: {cognito-identity, eu-central-1} was not found in region metadata, trying to construct an endpoint using the standard pattern for this region: 'cognito-identity.eu-central-1.amazonaws.com'

但是当我尝试获取数据时,我会得到:

However when I try to fetch data I get:


用户:arn:aws:sts :: XXX:assumed-role / XXX / CognitoIdentityCredentials是未授权执行的
:dynamodb:资源上的GetItem :
arn:aws:dynamodb:us-east-1:XXX:table / XXX

User: arn:aws:sts::XXX:assumed-role/XXX/CognitoIdentityCredentials is not authorized to perform: dynamodb:GetItem on resource: arn:aws:dynamodb:us-east-1:XXX:table/XXX

似乎连接到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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆