Morning, we're currently setting up AppSync auth w...
# sst
m
Morning, we're currently setting up AppSync auth with an existing user pool and running into some issues. We've tried as follows with no deployment issues but run into 500s when querying in the AppSync console. We can't seem to track down useful logs either. Any thoughts/suggestions?
Copy code
const userPool = cognito.UserPool.fromUserPoolArn(
      this,
      // does this id matter?
      'dev-user-pool',
      process.env.AWS_USER_POOL_ARN,
    )

    const api = new sst.AppSyncApi(this, 'v2', {
      graphqlApi: {
        schema: 'src/schema/schema.graphql',
        authorizationConfig: {
          defaultAuthorization: {
            authorizationType: appsync.AuthorizationType.USER_POOL,
            userPoolConfig: {
              userPool: userPool,
            },
          },
        },
        logConfig: {
          excludeVerboseContent: false,
          fieldLogLevel: appsync.FieldLogLevel.ALL,
        },
      },
      resolvers: {
        'Query    projects': 'src/get-projects.main',
        'Mutation    createProject': 'src/create-project.main',
      },
    })
f
Hey @Michael Orcutt,
// does this id matter?
Nope, for imported constructs, it’s just an id for CDK to reference it internally.
I’d first try to figure out whether the auth failed or the lambda failed. Can you check if the resolver Lambda functions were called?
If you are running
sst start
, you should see invocation in your terminal when querying from the AppSync console.
m
Nothing is coming through the terminal when running
sst start
and we cannot see any logs showing that the resolver func has been called
f
Can you try commenting out the
authorizationConfig
(ie. making the API public) and see if querying works from the console?
m
It does work that way
f
I see. In AppSync console, can you authenticate as a cognito user?
m
Yep, we can
The error changes from a 401 to a 500 after logging in as a cognito user
f
I see. It’s most likely auth related since the resolvers are not getting invoked. I’m not too familiar with AppSync, but I’d try turning on logging and look at X-Ray and see if it provides more details on the error.
m
The problem ended up being that we were deploying AppSync in
us-east-1
and our Cognito user pool was in
us-east-2
Thanks for helping out here @Frank!
f
Ah that makes sense. Np! Glad u got it working!