眠気.jl

投稿=不定期

Next.jsをAmplifyでホスト(SSR)したらbuildが通っていても503が出てたのを解決

注意

自分の場合は解決したという備忘録

現象

amplify consoleから見えるステータスはすべてグリーンの状態だが、アクセスすると

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. We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.
Generated by cloudfront (CloudFront)
Request ID: [リクエストID]

Lambda@EdgeにSQS権限は手動で付与済み 503 issues when deploying with NextJS@^11.1.2 · Issue #2326 · aws-amplify/amplify-hosting · GitHub

結論

Lambda@Edge Funcitonはus-east-1のみで動作します、default regionをap-northeast-1にしていても勝手にそうなります。
自分の場合はamplify consoleとか諸々はap-northeast-1でLambda@Edge Functionのみ別リージョンにいたので怒られてました。
amplifyプロジェクトごとus-east-1に全部ぶち込んで解決しました(解決か...?)

Amplify Hosting を使用したサーバーサイドレンダリングアプリをデプロイ - AWS Amplifyホスティング

Lambda @Edge 関数は米国東部 (バージニア北部) リージョンで作成されます Next.js アプリケーションをデプロイすると、Amplify は Lambda @Edge 関数を作成して、以下のコンテンツをカスタマイズします。 CloudFront 配信します。
->これ誰か暇な活動家がアジア人差別だのなんだのぴーぴー騒いで日本対応させてほしい。
チュートリアル: シンプルな Lambda@Edge 関数の作成 - Amazon CloudFront

メモ

Lambda@Edge Functionはus-east-1のみで動作可