title: Cognito & DynamoDB: "not authorized to perform: dynamodb:UpdateItem on resource"
body: <p>After following exactly the <a href="http://docs.aws.amazon.com/mobile/sdkforandroid/developerguide/dynamodb_om.html" rel="nofollow">"Getting started" guide for Amazon DynamoDB on Android</a>, I end up with all the right tables created, role policies, etc. and that code:</p>
  
  <pre><code>CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(
          getApplicationContext(),
          "eu-west-1:01234567-abcd-8901-efab-234567890123", // Identity Pool ID
          Regions.EU_WEST_1 // Region
  );
  
  AmazonDynamoDBClient ddbClient = new AmazonDynamoDBClient(credentialsProvider);
  final DynamoDBMapper mapper = new DynamoDBMapper(ddbClient);
  
  final Book book = new Book("My new book"); // Simplified version of Book
  new Thread(new Runnable() {
      @Override
      public void run() {
          mapper.save(book);
          Log.v("Sync", "Book saved!");
      }
  }).start();
  </code></pre>
  
  <p>Important note, the biggest (but unoticeable) difference with the tutorial is that I'm based in Europe so my region is <code>eu-west-1</code> (Ireland).</p>
  
  <p>And yet, having followed everything correctly, I get the following error:</p>
  
  <pre><code>com.amazonaws.AmazonServiceException: User: arn:aws:sts::012345678901:assumed-role/Cognito_BookUnauth_Role/CognitoIdentityCredentials is not authorized to perform: dynamodb:UpdateItem on resource: arn:aws:dynamodb:us-east-1:012345678901:table/Books (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: AccessDeniedException; Request ID: 05OLSSM8F8EN15SO0JD8VELCNNVV4KQNSO5AEMVJF66Q9ASUAAJG)
      at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:709)
      at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:385)
      at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:196)
      at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.invoke(AmazonDynamoDBClient.java:3257)
      at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.updateItem(AmazonDynamoDBClient.java:965)
      at com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBMapper$SaveObjectHandler.doUpdateItem(DynamoDBMapper.java:1173)
      at com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBMapper$2.executeLowLevelRequest(DynamoDBMapper.java:873)
      at com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBMapper$SaveObjectHandler.execute(DynamoDBMapper.java:1056)
      at com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBMapper.save(DynamoDBMapper.java:904)
      at com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBMapper.save(DynamoDBMapper.java:688)
      at com.davidferrand.books$4.run(MainActivity.java:136)
      at java.lang.Thread.run(Thread.java:818)
  </code></pre>