I am trying to save a test record to amazon dynamodb table from Android.
Context mContext = this.getApplicationContext();
CognitoCachingCredentialsProvider cognitoProvider = new CognitoCachingCredentialsProvider(
mContext, // get the context for the current activity
"xxxxxxxxxxxxxx",
"us-east-1:dsfhjhsd-sdfsfds-sdffds-dsffs",
"arn:aws:iam::7777777777:role/Cognito_CustMobAnalyticsUnauth_DefaultRole",
"YOUR AUTHENTICATED ARN HERE",
Regions.US_EAST_1
);
try {
AmazonDynamoDBClient ddb = new AmazonDynamoDBClient(cognitoProvider);
//ddb.setRegion(Region.getRegion(Regions.US_EAST_1));
DynamoDBMapper mapper = new DynamoDBMapper(ddb);
androTest mytest = new androTest();
mytest.setMyKey("testKey-1");
try {
mapper.save(mytest);
} catch (AmazonServiceException ex) {
Log.e("CustomError", "---> " + ex.getLocalizedMessage());
}
} catch (Exception e) {
// This will catch any exception, because they are all descended from Exception
Log.e("CustomError", "---> " + e.getLocalizedMessage());
Log.e("CustomError", "---> " + e.getMessage());
}
I am getting the following message while executing and data is not updated. I am using unauthenticated arn.
D/CognitoCachingCredentialsProvider﹕ Loading credentials from SharedPreferences
D/CognitoCachingCredentialsProvider﹕ No valid credentials found in SharedPreferences
E/CustomError﹕ ---> null
E/CustomError﹕ ---> null
Following is the role policies
{
"Version": "2012-10-17",
"Statement":[{
"Effect":"Allow",
"Action":"cognito-sync:*",
"Resource":["*"]
}]
}
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmtxxxxxx",
"Effect": "Allow",
"Action": [
"dynamodb:DeleteItem",
"dynamodb:DescribeTable",
"dynamodb:GetItem",
"dynamodb:PutItem",
"dynamodb:Query",
"dynamodb:Scan",
"dynamodb:UpdateItem",
"dynamodb:UpdateTable"
],
"Resource": [
"arn:aws:dynamodb:us-east-1:663633636363:table/androTest"
]
}
]
}
Following is the trust policy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"Federated": "cognito-identity.amazonaws.com"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"cognito-identity.amazonaws.com:aud": "us-east-1:chgsdhg0-sdds-sdsd-7687668c05"
},
"ForAnyValue:StringLike": {
"cognito-identity.amazonaws.com:amr": "unauthenticated"
}
}
}
]
}
Aucun commentaire:
Enregistrer un commentaire