Closed chris-lee-code closed 2 years ago
Hi :wave:, thanks for opening! While we look into this...
If this issue is related to custom domains, be sure to check the custom domains troubleshooting guide to see if that helps. Also, there is a more general troubleshooting FAQ that may be helpful for other questions.
Lastly, please make sure you've specified the App ID
and Region
in the issue!
@chrisbonifacio Hi! The problem is not related to the custom domains. I'm just using the amplifyapp.com domain as given by default.
region: us-east-2 App ID: dekc4p24zvjqs
Hi @chris-lee-code 👋🏽 , can you provide reproduction steps so we can reproduce this behavior and try to diagnose the cause?
hello @hloriana! Sure, I can. But I would like to know what are some pieces of information you would need for the reproduction.
Also, do you guys have a history of version support of AWS Amplify to NextJS? Mainly, the issue was caused by the too recent version that Amplify yet doesn't support according to other bug reports.
@chris-lee-code we support 11.1.2, so your deployment should be working 🤔 . I just need to know what steps you took to deploy your application. Did you follow these instructions: https://docs.aws.amazon.com/amplify/latest/userguide/server-side-rendering-amplify.html
Hi @chris-lee-code, The 503 error in your screenshot is likely due to missing IAM permissions on the Lambda@Edge functions.
We create those functions along with their IAM roles on the first deployment, but if you added new permissions on your Amplify App IAM role after the first deployment, unfortunately we don't propagate those to the Lambda functions on subsequent deployments. The workaround is to find those IAM roles associated to the L@E functions in your account, and add the permissions manually.
Here is a list of all the permissions that your app may need: https://github.com/aws-amplify/amplify-console/blob/master/FAQ.md#error-accessdenied-access-denied . If you are using ISR for example, then you need the sqs:
permissions.
@ferdingler Thanks for the advice! I haven't got any chances to try out the suggestions yet.
By the way, I also realized there's a size limit for the Amplify app deployment (I believe 50MB?).
Is there any effective and accurate way for me to test the file size of the entire website? Thanks!
Hi @chris-lee-code Are you using webpack 5 (the default in Next 11)? If so, you need to downgrade. See https://github.com/aws-amplify/amplify-console/issues/1872
Is this issue resolved yet?
I have exactly the same issue (with ISR), and also confirmed that the IAM role permissions include all mentioned in https://github.com/aws-amplify/amplify-console/blob/master/FAQ.md#error-accessdenied-access-denied.
However, I still see the 503 errors.
The tricky part is that there won't be any 503 error right after a fresh deployment. The 503 errors will only show up after a certain period, like roughly 12 - 24 hours.
Any one see the same kind "delayed“ 503 errors?
Also seeing this issue, have the 503 errrors right off the back from a deployed page using get static props/paths.
@interstellard based on the link you provided, do you know what is meant by the 'Amplify App Role' they mentioned for the IAM permissions? What role name does that translate to in the IAM console?
@jnastaskin I think they were referring to the "IAM roles" (https://console.aws.amazon.com/iam/home?#/roles) for the Lambda functions used in the Amplify App Deployment.
And here are the steps to find out the exact role used in the deployment:
(1) In each build (connected branch) of the Amplify app, there's a 'Deploy' tab showing the Lambda functions (along with each function ID) used for the deployment, such as "SSR Lambda@Edge", "ISR Lambda", etc.
(2) In the Lambda Functions page (e.g. https://console.aws.amazon.com/lambda/home?region=us-east-1#/functions), you can find the corresponding Lambda functions using the function IDs, and then find the "Role name" in the function's "Configuration" tab.
(3) Click the "Role name" ID and it will link you to the role details page, and you can modify the policy manually (using the {} JSON view).
@interstellard amazing, thank you!
Hi sorry to open this up again. I'm still having this issue. I followed @interstellard 's guide but it still seem broken. Is there any updates on this? Cheers
There are several issues still with getting Next and Amplify to work nicely. The best two pages I found are here https://github.com/aws-amplify/amplify-hosting/blob/main/FAQ.md#error-accessdenied-access-denied And here https://aws.amazon.com/blogs/mobile/host-a-next-js-ssr-app-with-real-time-data-on-aws-amplify/ (Including the comments below the blog post)
In my case I made several key changes 1-Install or downgrade to Next 10.0.0.8 (npm install next@10.0.8) 2-Be sure all of your Environment variables are added to Amplify’s console 3-Add this Env variable too: AMPLIFY_NEXTJS_EXPERIMENTAL_TRACE=true 4-Modify your next.config.js for the Environment Variables Workaround mentioned in the 1st article above.
Also, it doesn’t hurt to test an api/ file with bare min code to ensure there aren’t errors in your code. LambdaEdge doesn’t seem to have great logging. )At least not that I found)
Hi @Hadjimina , Currently, Amplify doesn't support Next 12. If you are seeing 503 error in Next 12, please try to downgrade to Next 11.
If you are already in Next 11 or lower version, please follow this instruction to attach logs here https://github.com/aws-amplify/amplify-hosting/blob/main/FAQ.md#access-lambda-edge-logs . Thanks
Hi, we have deployed a fix for NextJS API routes throwing a 503 error. To get the fix, simply rerun a build/deploy on your app again.
Hi @Hadjimina , Currently, Amplify doesn't support Next 12. If you are seeing 503 error in Next 12, please try to downgrade to Next 11.
If you are already in Next 11 or lower version, please follow this instruction to attach logs here https://github.com/aws-amplify/amplify-hosting/blob/main/FAQ.md#access-lambda-edge-logs . Thanks
I downgraded to Next 11 and continue to get the error. Like @interstellard, the error doesn't present immediately - rather only after navigating around the site (for me, it typically takes ~20 clicks on various pages). Seems to be an issue with getStaticPaths
and/or getStaticProps
... I was not getting the error when using getServerSiderProps
.
Note I had to upgrade to Next 11+ since 10 was throwing a bundle size error (too large) when using getStaticProps
, despite exclusively using incremental static regeneration. I suspect it has something to do with ISR since it's only erroring-out on those pages.
Update: Seems as though adding the SQS permissions (used full access to be certain I applied the correct permissions) to the deployment lambda permissions did the trick.
just wanna provide some input, I have been having the same issues and tried numerous methods for the last 2 days and finally solved it.
The problem is that I have revalidate in my return of getStaticProps, commented it out makes the error goes away and I this is one link I found to be useful https://stackoverflow.com/questions/71432161/aws-amplify-503-error-when-using-next-js-getstaticprops-revalidate
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Before opening, please confirm:
JavaScript Framework
React, Next.js
Amplify APIs
Authentication, GraphQL API, DataStore
Amplify Categories
hosting
Environment information
Describe the bug
Having an issue with deploying and hosting the website I made with Next.JS with the version of ^11.1.2. I do see four green checks with provisioning, build, etc. So I don't think it's the problem with the AWS Amplify Console deployment.
I have seen previous bug reports saying that several recent versions of Next.JS are not supported by AWS Amplify yet. Could you provide me the version of the most recent one that does work on Amplify?
Expected behavior
Should work...
Reproduction steps
https://beta.dekc4p24zvjqs.amplifyapp.com/
Code Snippet
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response