I'm trying to debug an issue on a page that has a getServerSideProps handler, but after deploying the application I cannot find the log group for my lambda function in any of the regions.
The application uses [email protected] with getServerSideProps.
My understanding is that after deployment there should be automatically be a /aws/lambda/us-east-1.<function-name> log group in every region, correct?
My serverless.yml config:
ssr:
component: serverless-next.js
inputs:
domain:
- ${env.subdomain}
- xxxxxxx
memory: 2048
timeout:
defaultLambda: 20
apiLambda: 15
bucketName: xxxxxxxx
policy: ${env.policy}
serverless.js:
class Deploy extends Component {
async default(inputs = {}) {
process.env.policy = getConfig().ssrPolicyArn;
process.env.subdomain = `subdomain-${process.env.ENV}`;
const template = await this.load('@serverless/template', process.env.ENV);
const output = await template({ template: 'serverless.yml' });
return output;
}
...
...
My custom policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "dynamodb:Query",
"Resource": "arn:aws:dynamodb:eu-west-1:xxxxxx:table/wwwwwww"
},
{
"Sid": "VisualEditor1",
"Effect": "Allow",
"Action": [
"logs:CreateLogStream",
"logs:CreateLogGroup",
"logs:PutLogEvents"
],
"Resource": "*"
}
]
}
Same here. Any clues?
Here too. I'm having a 500 error and can't debug it!
For me, the log groups were created in a different region, not us-east-1. I figured I had a configuration error, but if the same happened to either of you, maybe it's an issue here.
I didn鈥檛 found the logs. If I go to the lambda function, then monitoring, it doesn鈥檛 show any activity. There is a button to open CloudWatch logs, but after clicking it and opening CloudWatch it throws an error stating that it couldn鈥檛 open the log stream.
Did you also check the other regions in Cloudwatch? The button from the AWS Lambda console won't work if the log groups are in another region, because that link is to us-east-1.
I couldn't find it. In which region was yours? My "default" region is us-east-1
Mine were created in us-east-2.
I found nothing... I think it isn't being created.
Does anyone know the trick to logging the api in this framework?
Also not working for me, checked other regions and no log groups. I did, however, find a log group from a project with the exact same setup from January.
_Update: I created a test event directly in the Lambda UI and it created the log group was created and logged properly. Subsequent errors/events through the actual application are still not logging._
I'm facing the same problem, there an error 500 when I access the app url, and there is no way to know whats going on, looks like its only loading static content, and doesn't execute the lambda at all
Hi folks, getServerSideProps still isn鈥檛 supported in the serverless component. See this RFC for details https://github.com/danielcondemarin/serverless-next.js/issues/355 how it will be implemented.
Also if you want to check the logs remember is Lambda@Edge so you will need to select the region where your incoming traffic is to see the log group.
Thanks @danielcondemarin at the end I could find the logs in another region, and I could fix my app 馃憤 btw, thanks a lot for creating this tool it's impressive how easy is to deploy stuff 馃槃
This is probably related to the application being served with Lambda@Edge. When a user requests your website it will be rendered by a lambda in a AWS region close to that user. The resulting CloudWatch logs will then get generated in that region.
I'm located in Sweden and got logs for my requests in the eu-west-2 region (London). So try looking for logs in the region closest to you! 馃搷 馃檪
AWS has some documentation for debugging Lambda@Edge functions here: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-edge-testing-debugging.html
Closing this as it now has been answered.
@danielcondemarin I've gone through every single region, and still cannot find the log group.
I created a test event directly in the Lambda UI and it created the log group was created and logged properly. Subsequent errors/events through the actual application are still not logging to this group though.
I even opened up the permissions completely:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"logs:*",
],
"Resource": "*"
}
]
}
Still not logging. Any suggestions on where to poke around? I've exhausted all documentation that I can find at this point, and would appreciate any ideas.
Thank you! 馃檱
I heard back from Amazon AWS support, and it turned out to be an issue with the Lambda function link to CloudWatch Logs. When clicking the CloudWatch link within the Lambda interface, it will now show log groups, even if you switch through each region that Lambda@Edge may have run through.
If you go into CloudFront interface, click the distribution, then go to metrics, and select your Lambda function and open in CloudWatch for that region, it will show up.
It's a bit tricky finding them, but not an issue with serverless-next.js 馃憤
Hey this was really annoying, I would just go to CloudWatch directly and find the appropriate Log Group. Amazing if you kicked off the fix on the AWS side!
Most helpful comment
This is probably related to the application being served with Lambda@Edge. When a user requests your website it will be rendered by a lambda in a AWS region close to that user. The resulting CloudWatch logs will then get generated in that region.
I'm located in Sweden and got logs for my requests in the eu-west-2 region (London). So try looking for logs in the region closest to you! 馃搷 馃檪
AWS has some documentation for debugging Lambda@Edge functions here: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-edge-testing-debugging.html