Ich habe eine Tabelle mit einigen Elementen. Ich versuche, feinkörnige Zugriffssteuerung (Zugriff auf bestimmte Attribute in einer Tabelle beschränken) auf unauth (ich möchte bestimmte Attribute für Benutzer, die noch nicht authentifiziert sind), wo Benutzer auf bestimmte Attribute basierend auf folgenden URL Using IAM Policy Conditions for Fine-Grained Access Control.Amazon DynamoDB: feinkörnige Zugriffskontrolle Scannen mit spezifischen Attributen
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "LimitAccessToSpecificAttributes",
"Effect": "Allow",
"Action": [
"dynamodb:GetItem",
"dynamodb:Query",
"dynamodb:BatchGetItem",
"dynamodb:Scan"
],
"Resource": [
"arn:aws:dynamodb:us-west-2:AccountID:table/MyTable"
],
"Condition": {
"ForAllValues:StringEquals": {
"dynamodb:Attributes": [
"startDate",
"endDate"
]
},
"StringEqualsIfExists": {
"dynamodb:Select": "SPECIFIC_ATTRIBUTES",
"dynamodb:ReturnValues": [
"NONE",
"UPDATED_OLD",
"UPDATED_NEW"
]
}
}
}
]
}
wenn ich folgende Rolle bin Entfernen funktioniert es:
"Condition": {
"ForAllValues:StringEquals": {
"dynamodb:Attributes": [
"startDate",
"endDate"
]
},
"StringEqualsIfExists": {
"dynamodb:Select": "SPECIFIC_ATTRIBUTES",
"dynamodb:ReturnValues": [
"NONE",
"UPDATED_OLD",
"UPDATED_NEW"
]
}
Das Problem ist, dass, wenn ich meinen Code leite (android) ich folgende Ausnahme bin immer:
Benutzer: arn: aws: sts :: AccountID: angenommen-Rolle/Cognito_XXXUnauth_Role/CognitoIdentityCredentials ist nicht erlaubt zu erfüllen: dynamodb: Scan auf Ressource: arn: aws: dynamodb: us-east-1: AccountID: table/MyTable (Dienst: AmazonDynamoDB; Statuscode: 400; Fehlercode: AccessDeniedException;
Ich würde gerne wissen, was ich falsch mache, die die Ausnahme verursacht. Gibt es eine andere Möglichkeit, bestimmte Attribute zu erhalten?
ich folgenden Android Code verwenden:
CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(getApplicationContext(),
"identityPoolId",
Regions.US_EAST_1
);
AmazonDynamoDBClient ddb = new AmazonDynamoDBClient(credentialsProvider);
ScanRequest scanRequest = new ScanRequest();
scanRequest = scanRequest.withProjectionExpression("startDate, endDate");
scanRequest.setTableName("MyTable");
try {
ScanResult scanResult = ddb.scan(scanRequest);
} catch (Exception ex) {
log(ex.getMessage());
}
Jede Hilfe würde geschätzt.