I have setup an AppSync GraphQL API which uses two authorization modes, default being Cognito and other being IAM. Now I want to run this query even before the user is logged in for which I will be using the IAM authorization mode. This Api will access the dynamodb table through a lambda function.
Based on my understanding I guess the user can perform a read operation even if they are not logged in by using the IAM users permission that is attached to the Amplify project. Here I have the below policy/permission attached to the IAM user. Please let me know if I am thinking right.
Here is the policy that I created for executing a query operation on my API
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "appsync:GraphQL",
"Resource": "arn:aws:appsync:<REGION>:<ACCOUNT>:apis/<APIID>/types/Query/fields/getUserById"
}
]
}
Now when I run using the IAM authorized mode inside the AppSync console, I still get the unauthorized error.
Here is the snip of the console - 