Cognito with DynamoDB - 连接到 us-east-1 而不是 eu-central-1

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

我正在使用 AWS DynamoDB 和 Cognito 来授权来自 Android 的访问(到目前为止未授权用户)。 我的数据库在 eu-central-1 中,我使用 com.amazonaws:aws-android-sdk-ddb:2.2.8,如:

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} 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'

然而,当我尝试获取数据时,我得到:

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 而不是指定的 EU。角色可以访问适当的数据库资源(欧盟资源),美国东部没有 dynamoDB。有什么我应该指定欧盟区域但我错过的想法吗?

哦,正确的做法是:

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