I’m new to Serverless. I’ve been carefully following Alex DeBrie’s article, Building a chat application using AWS AppSync and Serverless. I cloned his Github repo and it seems to build correctly. But when I run the app from the front directory, after creating a userid and logging in, the app generates a POST with this data:
{“query”:“query GetMessages($filter: String) {\n getMessages(filter: $filter) {\n messageId\n body\n createdAt\n handle\n }\n}\n”,“variables”:{}}
and AWS returns a 500 Internal Server Error with
{
“errors” : [ {
“errorType” : “InvalidUserPoolException”,
“message” : “Invalid Cognito User pool id or region”
} ]
}
I have validated that the values in stack.json match the ones shown in CloudFormation.
Any ideas about why this would happen and/or how I can troubleshoot it?
*** Update ***
I’ve fixed the problems. I’m posting this here in the hopes of saving someone else a lot of wasted time. There are actually 2 problems, both on the backend configuration.
-
It appears that Serverless/AppSync is not populating the user pool field in AppSync/Settings/Default Authorization Mode/Configuration. I fixed it by manually setting this to my User Pool, but someone should try to figure out why it’s not being set correctly in the first place.
-
As documented in this 2017 Bug Report, you need to add another resource to serverless.yml:
Resource: "arn:aws:dynamodb:us-east-1: : "
As mentioned in the Bug Report, it’s not clear why this is necessary, i.e., the specific ARNs should work. Perhaps someone else can figure this out once and for all?
There’s also some outdated information in the README.md file in the github repo. It states that amplify will generate a .amplifyrc file but that has not been true beginning with amplify CLI version 1.1.2.
Hope this helps.