question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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."

See original GitHub issue

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?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:19

github_iconTop GitHub Comments

2reactions
dphangcommented, Nov 26, 2020

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).

0reactions
plusplushqcommented, Jan 30, 2021

Yea @dphang @zerbinidamata @grantmontgomery I’m quite sure now that this isn’t an issue with the serverless-next plugin, but rather something within our own implementations.

I’ve just deployed this apollo client/ server example from next that also has API routes and it works flawlessly, also on API Routes. https://github.com/vercel/next.js/tree/canary/examples/api-routes-apollo-server-and-client Going to look into my setup later and compare with that example

Read more comments on GitHub >

github_iconTop Results From Across the Web

503 ERROR The request could not be satisfied (AWS Amplify)
The Lambda function associated with the CloudFront distribution is invalid or doesn't have the required permissions. We can't connect to the ...
Read more >
Cloudfront 503 Error on api route call with Apollo Server and ...
When I run build Serverless seems to create a lambda function for my Apollo Server handler, but I don't know where to look...
Read more >
HTTP 503 status code (Service Unavailable)
An HTTP 503 status code (Service Unavailable) typically indicates a performance issue on the origin server. In rare cases, it indicates that CloudFront ......
Read more >
Deploying with AWS Lambda - Apollo GraphQL Docs
In this guide, we'll walk through how to deploy Apollo Server's AWS Lambda integration to AWS Lambda using the Serverless framework.
Read more >
CloudFront with Lambda@Edge: 503 The request could not ...
Here is the erorr message The Lambda function associated with the CloudFront distribution is invalid or doesn't have the required permissions. ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found