2017-10-06 8 views
0

Ich habe eine Amazon Dynamodb-Tabelle mit Partition Schlüssel aus der Benutzer-ID (von Facebook oder Google) und andere Zeichen. Ich weiß Wildcard kann verwendet werden, um die Eigenschaften einer feinkörnigen Zugriffsrichtlinie anzugeben, aber ich konnte nicht den Platzhalter in dynamodb:LeadingKeys arbeiten.Kann das Platzhalterzeichen (*) in der Feinzugriffsrichtlinie für dynamodb verwendet werden?

Hier ist die Arbeitspolitik:

{ 
    "Version": "2012-10-17", 
    "Statement": [ 
     { 
      "Effect": "Allow", 
      "Action": [ 
       "dynamodb:BatchGetItem", 
       "dynamodb:BatchWriteItem", 
       "dynamodb:DeleteItem", 
       "dynamodb:GetItem", 
       "dynamodb:PutItem", 
       "dynamodb:Query", 
       "dynamodb:UpdateItem" 
      ], 
      "Resource": [ 
       "arn:aws:dynamodb:<region>:<...>:table/<table-name>" 
      ], 
      "Condition": { 
       "ForAllValues:StringEquals": { 
        "dynamodb:LeadingKeys": [ 
         "g_${accounts.google.com:sub}" 
        ] 
       } 
      } 
     } 
    ] 
} 

Dies ist jedoch nicht funktioniert:

{ 
    "Version": "2012-10-17", 
    "Statement": [ 
     { 
      "Effect": "Allow", 
      "Action": [ 
       "dynamodb:BatchGetItem", 
       "dynamodb:BatchWriteItem", 
       "dynamodb:DeleteItem", 
       "dynamodb:GetItem", 
       "dynamodb:PutItem", 
       "dynamodb:Query", 
       "dynamodb:UpdateItem" 
      ], 
      "Resource": [ 
       "arn:aws:dynamodb:<region>:<...>:table/<table-name>" 
      ], 
      "Condition": { 
       "ForAllValues:StringEquals": { 
        "dynamodb:LeadingKeys": [ 
         "*_${accounts.google.com:sub}" 
        ] 
       } 
      } 
     } 
    ] 
} 

Antwort

0

ich die Lösung für dieses Problem gefunden. Verwenden Sie statt ForAllValues:StringEqualsForAllValues:StringLike.

Die Arbeitspolitik ist so:

{ 
    "Version": "2012-10-17", 
    "Statement": [ 
     { 
      "Effect": "Allow", 
      "Action": [ 
       "dynamodb:BatchGetItem", 
       "dynamodb:BatchWriteItem", 
       "dynamodb:DeleteItem", 
       "dynamodb:GetItem", 
       "dynamodb:PutItem", 
       "dynamodb:Query", 
       "dynamodb:UpdateItem" 
      ], 
      "Resource": [ 
       "arn:aws:dynamodb:<region>:<...>:table/<table-name>" 
      ], 
      "Condition": { 
       "ForAllValues:StringLike": { 
        "dynamodb:LeadingKeys": [ 
         "*_${accounts.google.com:sub}" 
        ] 
       } 
      } 
     } 
    ] 
} 

dauerte eine Weile, diese Referenz zu finden: http://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements.html#AccessPolicyLanguage_ConditionType

Verwandte Themen