How to use DynamoDB fine grained access control with Cognito User Pools?

后端 未结 1 1880
天涯浪人
天涯浪人 2021-01-01 21:24

I\'m having trouble understanding how to use fine-grained access control on DynamoDB when logged in using Cognito User Pools. I\'ve followed the docs and googled around, but

相关标签:
1条回答
  • 2021-01-01 22:13

    The policy variable "${cognito-identity.amazonaws.com:sub}" is not the user sub which you get from Cognito user pools. It is in fact the identity id of a user which is generated by the Cognito Federated Identity service when you federate a user from Cognito User Pools with Federated identity service.

    Since, the value in "${cognito-identity.amazonaws.com:sub}" never matches what you have in your DynamoDB row, it fails with AccessDenied. For this to work, the userId in your Dynamo entry should actually be the identity id, not sub. Currently, there is no direct link between IAM policy variables and Cognito User Pools service.

    Here are some doc links which might help.
    1. IAM roles with Cognito Federated Identity Service
    2. Integrating User Pools with Cognito Federated Identity Service

    0 讨论(0)
提交回复
热议问题