Open Rafcin opened 2 years ago
Also I have updated the backend role with the proper permissions
"Action": [
"acm:DescribeCertificate",
"acm:ListCertificates",
"acm:RequestCertificate",
"cloudfront:CreateCloudFrontOriginAccessIdentity",
"cloudfront:CreateDistribution",
"cloudfront:CreateInvalidation",
"cloudfront:GetDistribution",
"cloudfront:GetDistributionConfig",
"cloudfront:ListCloudFrontOriginAccessIdentities",
"cloudfront:ListDistributions",
"cloudfront:ListDistributionsByLambdaFunction",
"cloudfront:ListDistributionsByWebACLId",
"cloudfront:ListFieldLevelEncryptionConfigs",
"cloudfront:ListFieldLevelEncryptionProfiles",
"cloudfront:ListInvalidations",
"cloudfront:ListPublicKeys",
"cloudfront:ListStreamingDistributions",
"cloudfront:UpdateDistribution",
"cloudfront:TagResource",
"cloudfront:UntagResource",
"cloudfront:ListTagsForResource",
"iam:AttachRolePolicy",
"iam:CreateRole",
"iam:CreateServiceLinkedRole",
"iam:GetRole",
"iam:PutRolePolicy",
"iam:PassRole",
"lambda:CreateFunction",
"lambda:EnableReplication",
"lambda:DeleteFunction",
"lambda:GetFunction",
"lambda:GetFunctionConfiguration",
"lambda:PublishVersion",
"lambda:UpdateFunctionCode",
"lambda:UpdateFunctionConfiguration",
"lambda:ListTags",
"lambda:TagResource",
"lambda:UntagResource",
"route53:ChangeResourceRecordSets",
"route53:ListHostedZonesByName",
"route53:ListResourceRecordSets",
"s3:CreateBucket",
"s3:GetAccelerateConfiguration",
"s3:GetObject",
"s3:ListBucket",
"s3:PutAccelerateConfiguration",
"s3:PutBucketPolicy",
"s3:PutObject",
"s3:PutBucketTagging",
"s3:GetBucketTagging",
"lambda:ListEventSourceMappings",
"lambda:CreateEventSourceMapping",
"iam:UpdateAssumeRolePolicy",
"iam:DeleteRolePolicy",
"sqs:CreateQueue",
"sqs:DeleteQueue",
"sqs:GetQueueAttributes",
"sqs:SetQueueAttributes",
"amplify:GetApp",
"amplify:GetBranch",
"amplify:UpdateApp",
"amplify:UpdateBranch"
],
With Next 11 I get this issue on the same page that complained about webpack.
{
"errorType": "Error",
"errorMessage": "Cannot find module '../../chunks/3266.js'\nRequire stack:\n- /var/task/pages/restaurant/[id].js\n- /var/task/index.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
"code": "MODULE_NOT_FOUND",
"requireStack": [
"/var/task/pages/restaurant/[id].js",
"/var/task/index.js",
"/var/runtime/UserFunction.js",
"/var/runtime/index.js"
],
"stack": [
"Error: Cannot find module '../../chunks/3266.js'",
"Require stack:",
"- /var/task/pages/restaurant/[id].js",
"- /var/task/index.js",
"- /var/runtime/UserFunction.js",
"- /var/runtime/index.js",
" at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)",
" at Function.Module._load (internal/modules/cjs/loader.js:667:27)",
" at Module.require (internal/modules/cjs/loader.js:887:19)",
" at require (internal/modules/cjs/helpers.js:74:18)",
" at Object.__webpack_require__.f.require (/var/task/pages/restaurant/[id].js:2885:28)",
" at /var/task/pages/restaurant/[id].js:2805:40",
" at Array.reduce (<anonymous>)",
" at Function.__webpack_require__.e (/var/task/pages/restaurant/[id].js:2804:67)",
" at Function.__webpack_require__.x (/var/task/pages/restaurant/[id].js:2901:33)",
" at /var/task/pages/restaurant/[id].js:2925:57"
]
}
When it comes to cannot find module...
error, I changed webpack version from 5 to 4 to fix it
@morishjs Are you on Next 11? In Next 12 you can't disable webpack5 anymore. In Next 11 you can, and I did try this although that created similar issues. I did that with 11.1.13, maybe it will work with 11.1.12. I'll test it out.
I've deployed this before, in my original app I have a deployment that used webpack 5 and Next 12.0.2 and it worked. I don't think it's webpack directly, I'm also missing the ISR and Image services so something during deployment messed up.
11.1.13 Also seems to have a bug where it complains that the paths pages/ and pages/restaurant[id] have invalid exports and can't be compiled. 11.1.12 and 12.0.2 seem fine.
Thanks, @morishjs, and @Rafcin.
I also had the 503 issues and solved them in the following ways:
AMPLIFY_NEXTJS_EXPERIMENTAL_TRACE: true
in environments of AWS Amplify App as mentioned here.@dhavall08 I can't downgrade to 4 and I've seen 4 work. I have experimental trace set in my config and I have the env car set through the console.
The issue is also I'm missing resources during deployment like the ISR lambdas and image optimizer
11.1.13 Also seems to have a bug where it complains that the paths pages/ and pages/restaurant[id] have invalid exports and can't be compiled. 11.1.12 and 12.0.2 seem fine.
Hi @Rafcin 👋🏽 for clarification, were you able to successfully deploy your apps with 11.1.12 and 12.0.2?
@hloriana Hi! I was able to deploy the apps in both versions. The app renders correctly and the only issues are the Next/image components don't load because the Image Optimizer lambda never deployed, and one of my pages, the restaurant page that displays the restaurant returns a 503 error.
@hloriana Depending on the NextJS version I get the following errors in CloudWatch when I visit the 503 page. Also I've opened a ticket with AWS set to Production system impaired. I switched my repo from NX to a standard monorepo now to get this to work.
{
"errorType": "Error",
"errorMessage": "Cannot find module '../../webpack-runtime.js'\nRequire stack:\n- /var/task/pages/restaurant/[id].js\n- /var/task/index.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
"code": "MODULE_NOT_FOUND",
"requireStack": [
"/var/task/pages/restaurant/[id].js",
"/var/task/index.js",
"/var/runtime/UserFunction.js",
"/var/runtime/index.js"
],
"stack": [
"Error: Cannot find module '../../webpack-runtime.js'",
"Require stack:",
"- /var/task/pages/restaurant/[id].js",
"- /var/task/index.js",
"- /var/runtime/UserFunction.js",
"- /var/runtime/index.js",
" at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)",
" at Function.Module._load (internal/modules/cjs/loader.js:667:27)",
" at Module.require (internal/modules/cjs/loader.js:887:19)",
" at require (internal/modules/cjs/helpers.js:74:18)",
" at /var/task/pages/restaurant/[id].js:1:56130",
" at Object.<anonymous> (/var/task/pages/restaurant/[id].js:1:56298)",
" at Module._compile (internal/modules/cjs/loader.js:999:30)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)",
" at Module.load (internal/modules/cjs/loader.js:863:32)",
" at Function.Module._load (internal/modules/cjs/loader.js:708:14)"
]
}
{
"errorType": "Error",
"errorMessage": "Cannot find module '../../chunks/3266.js'\nRequire stack:\n- /var/task/pages/restaurant/[id].js\n- /var/task/index.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
"code": "MODULE_NOT_FOUND",
"requireStack": [
"/var/task/pages/restaurant/[id].js",
"/var/task/index.js",
"/var/runtime/UserFunction.js",
"/var/runtime/index.js"
],
"stack": [
"Error: Cannot find module '../../chunks/3266.js'",
"Require stack:",
"- /var/task/pages/restaurant/[id].js",
"- /var/task/index.js",
"- /var/runtime/UserFunction.js",
"- /var/runtime/index.js",
" at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)",
" at Function.Module._load (internal/modules/cjs/loader.js:667:27)",
" at Module.require (internal/modules/cjs/loader.js:887:19)",
" at require (internal/modules/cjs/helpers.js:74:18)",
" at Object.__webpack_require__.f.require (/var/task/pages/restaurant/[id].js:2885:28)",
" at /var/task/pages/restaurant/[id].js:2805:40",
" at Array.reduce (<anonymous>)",
" at Function.__webpack_require__.e (/var/task/pages/restaurant/[id].js:2804:67)",
" at Function.__webpack_require__.x (/var/task/pages/restaurant/[id].js:2901:33)",
" at /var/task/pages/restaurant/[id].js:2925:57"
]
}
The things I've tried to get it to work:
I also noticed my second app apps/news just terminates after building, and I'm unsure what that's about.
dntsgf2k4wg50
@hloriana any updates?
My NextJS build is going through and deploying but navigating to the page reads a
503 ERROR
The request could not be satisfied.
The Lambda function associated with the CloudFront distribution is invalid or doesn't have the required permissions.
This has started in the past 24 hours using the same code as was previously working. US-east-2.
@evan-resonare Same problem on us-west-2.
@Rafcin my issue seemed to fix itself today. For me, it must have been associated with the recent AWS outages in us-east-2 and us-east-1.
This didn't solve it for me
Still running into issues
Name: fox-apps/fox URL: https://dev.d30o3wao502f5x.amplifyapp.com ID: dev.d30o3wao502f5x Build: 28
Name: fox-apps/news
URL: https://dev.dntsgf2k4wg50.amplifyapp.com
ID: dntsgf2k4wg50
Build: 20
These are my current app ids that can't deploy.
New 503 error
{
"errorType": "Error",
"errorMessage": "Cannot find module 'next/dist/shared/lib/utils.js'\nRequire stack:\n- /var/task/pages/restaurant/[id].js\n- /var/task/default-handler-dca9fd08.js\n- /var/task/index.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
"code": "MODULE_NOT_FOUND",
"requireStack": [
"/var/task/pages/restaurant/[id].js",
"/var/task/default-handler-dca9fd08.js",
"/var/task/index.js",
"/var/runtime/UserFunction.js",
"/var/runtime/index.js"
],
"stack": [
"Error: Cannot find module 'next/dist/shared/lib/utils.js'",
"Require stack:",
"- /var/task/pages/restaurant/[id].js",
"- /var/task/default-handler-dca9fd08.js",
"- /var/task/index.js",
"- /var/runtime/UserFunction.js",
"- /var/runtime/index.js",
" at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)",
" at Function.Module._load (internal/modules/cjs/loader.js:746:27)",
" at Module.require (internal/modules/cjs/loader.js:974:19)",
" at require (internal/modules/cjs/helpers.js:93:18)",
" at Object.9232 (/var/task/pages/restaurant/[id].js:1:61257)",
" at t (/var/task/webpack-runtime.js:1:142)",
" at Object.7194 (/var/task/chunks/628.js:1:29572)",
" at t (/var/task/webpack-runtime.js:1:142)",
" at Object.887 (/var/task/pages/restaurant/[id].js:1:55153)",
" at t (/var/task/webpack-runtime.js:1:142)"
]
}
Hi @Rafcin, just updating this issue for visibility. To recap, we were able to troubleshoot and get your first app running. I'm still working on root-causing the dynamic routing issue we discovered and I'm investigating the build errors on the second app. I will update with more information once I've made progress with these action items. Thanks!
Any updates on this issue?
I upgraded from NextJs 11.1.2 to Next 12.3. I cannot see the Image. Gives the 503 error
But the weird thing is I am not using next/image but a normal HTML img tag
Tried downgrading to next@12.0.8 as suggested in https://github.com/aws-amplify/amplify-hosting/issues/2175 but still no luck
Before opening, please confirm:
App Id
arn:aws:amplify:us-west-2:707129987630:apps/d30o3wao502f5x
Region
us-west-2
Amplify Console feature
Build settings, Monorepo
Describe the bug
Quick and simple. I rewrote my app to stop using NX and just work with Yarn workspaces. After a few days it's finally deploying and it looks good. The issue revolves around the services that are deployed after build. When I deploy the app, the only services that are spun up are
SSR Lambda@Edge, CloudFront Domain and S3 Bucket
.It looks like ISR and Image optimization are both not created during deployment. When I check the lambda logs the only issue I get is
It's weird this now only appears on a single page that uses getSSRprops and takes a query param. Otherwise the site works (minus the images).
I read this could be a Next 12 issue, however, I solved the 503 error by removing the transpile modules plugin and I originally the day Next12 came out successfully deployed a Next 12 app with Webpack 5.
Expected behavior
The expected services that should be deployed are
SSR Lambda@Edge, CloudFront Domain, S3 Bucket, API Lambda@Edge, Image optimization, ISR Lambda and ISR SQS Queue.
Reproduction steps
PKG JSON
Amplify YML
App Id
d30o3wao502f5x
Next Config
Build Settings
No response
Additional information
No response