0
votes

I have a DynamoDb table in the eu-west-1 region (arn:aws:dynamodb:eu-west-1:blah, blah:table/TestMyDynoApp)

I get a credentials provider:

 CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(
                MainActivity.this,
                "eu-west-1:blah, blah", // Identity pool ID
                Regions.EU_WEST_1 // Region
        );

then I get a clint instance and try and get an instance of the table:

 AmazonDynamoDBClient dbClient = new AmazonDynamoDBClient(credentialsProvider);

        Table dbTable = Table.loadTable(dbClient, "TestMyDynoApp");

but I keep getting this error:

Caused by: com.amazonaws.AmazonServiceException: User: arn:aws:sts::blah, blah:assumed-role/Cognito_DynamoDbDemoUnauth_Role/CognitoIdentityCredentials is not authorized to perform: dynamodb:DescribeTable on resource: arn:aws:dynamodb:us-east-1:blah, blah:table/TestMyDynoApp (Service: AmazonDynamoDB; Status Code: 400; Error Code: AccessDeniedException; Request ID: EE2BA50DQ063FUGP2RDHPFTOO7VV4KQNSO5AEMVJF66Q9ASUAAJG)

its referencing the table in us-east-1 which does not exist! instead of my table in eu-west-1 which does exists!

why is this happening?

appreciate any assistance.

thanks

1

1 Answers

0
votes

Found the solution in another Stackoverflow question

before trying to get an instance of the table i should call:

 dbClient.setRegion(Region.getRegion(Regions.EU_WEST_1));

Really bad documentaion on Amazon's part. Their example shows setting the region in CognitoCachingCredentialsProvider() and does not mention having to set it separately!