问题
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