Cognito with DynamoDB - connecting to us-east-1 instead eu-central-1

坚强是说给别人听的谎言 提交于 2019-12-11 07:34:43

问题


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);

In logs I see:

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:

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

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?


回答1:


Oh, so proper way is:

ddbClient.setRegion(Region.getRegion(Regions.EU_CENTRAL_1));


来源:https://stackoverflow.com/questions/41793212/cognito-with-dynamodb-connecting-to-us-east-1-instead-eu-central-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!