serverless-next.js: 503 Error on api call with Apollo Server "The Lambda function associated with the CloudFront distribution is invalid or doesn't have the required permissions."

I’m deploying an application using the @sls-next/serverless-component plugin. I built out an api route with an Apollo Server, specifically “apollo-server-micro” because this is what’s suggested by other Next.js users. All my other api routes work, but I can’t access this one in production mode which you can see on my actual site at https://sekndapp.com/api/createNewUser. This is what my createNewUser.ts file looks like.


import { ApolloServer, gql } from "apollo-server-micro";

export const config = {
  api: {
    bodyParser: false,
  },
};

const apolloServer: ApolloServer = new ApolloServer({ typeDefs, resolvers });

const handler = apolloServer.createHandler({ path: `/api/createNewUser` });

export default handler;

And my serverless.yml file.

myNextApplication:
  component: "@sls-next/serverless-component@1.17.0"
  inputs:
    domain: "sekndapp.com"
    timeout: 30
    name:
      defaultLambda: resourceAPILambda
      apiLambda: resourceAPILambda2

I’m also having issues where I can’t see logs from my lambda functions in lambda. Is there a way to fix this or should I go with another way to deploy to AWS?

About this issue

Most upvoted comments

Will need more logs, please check here on how to get logs: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-edge-testing-debugging.html on how to get logs for Lambda@Edge - they are in the region closest to the viewer which is not necessarily in us-east-1 (where the Lambda is created in).