node.jsamazon-dynamodbamazon-dynamodb-indexaws-permissions

How to authorize users to access GSI


How do I authorizer all users to access a GSI? (In my case, the userIndex)

I can access the primary-index just fine. I successfully authorized all users to access the primary-index the following way:

enter image description here


Here I target the primary-index, which works just fine

enter image description here


Here I target the GSI, which doesn't work:

enter image description here


I tried adding dynamodb to my AuthStack at the two places you can see in the image below (to no avail). I doubt changing the AuthStack will do anything, since it is a lambda function that is making the Put request to DynamoDb (I might be wrong though).

enter image description here


Solution

  • I figured it out.

    First of all, you are not supposed to write to a gsi, only read.

    Secondly, when wantin gto query a gsi, you have to specify the TableName together with IndexName.

    The following works

    enter image description here