Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

503 ERROR - The Lambda function associated with the CloudFront distribution is invalid. Environment variable support for Labda@Edge #2084

Closed
IbrahimSam96 opened this issue Jul 23, 2021 · 11 comments
Labels
archived This issue has been locked. question Further information is requested ssr Server Side Rendering feature

Comments

@IbrahimSam96
Copy link

Provide additional details
I connected a SSR Next.js app repo, where amplify detected SSR pages and created SSR resources ( CloudFront, Default Edge Lambda, S3 bucket, API Edge Lambda, Image Optimization Edge Lambda ). The error I'm receiving s because Lambda@Edge doesn't support environment variables.
What AWS Services are you utilizing?
Amplify Console
Provide additional details e.g. code snippets
SSR Resources
SSRAmplify
CloudWatch Log
CloudWatchLogs

@IbrahimSam96 IbrahimSam96 added the question Further information is requested label Jul 23, 2021
@IbrahimSam96 IbrahimSam96 changed the title 503 ERROR - The Lambda function associated with the CloudFront distribution is invalid. Environment variable support 503 ERROR - The Lambda function associated with the CloudFront distribution is invalid. Environment variable support for Labda@Edge Jul 23, 2021
@github-actions
Copy link

Hi 👋, 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!

@RealDrewKlayman
Copy link

Environment variables have been added. Check to make sure you are adding them as described here:
#1987 (comment)

@IbrahimSam96
Copy link
Author

Environment variables have been added. Check to make sure you are adding them as described here:
#1987 (comment)

I did update my next.config.js file and the amplify terminal fails at build and gives me this error -

[WARNING]: (node:1239) [DEP_WEBPACK_MODULE_UPDATE_HASH] DeprecationWarning: Module.updateHash: Use new ChunkGraph API

@IbrahimSam96
Copy link
Author

I'm also using Firebase Admin which works only on Server Side.
WebPack Error

@RealDrewKlayman
Copy link

I don't think that has anything to do with Environment Variables not working...
Could be related to this: vercel/next.js#15576

@IbrahimSam96
Copy link
Author

I navigated the discussions and still unsure about the solution is!

package.JSON

{
  "name": "graphx",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start"
  },
  "dependencies": {
    "moment": "^2.29.1",
    "next": "^11.0.1",
    "nookies": "^2.5.2",
    "react": "^17.0.2",
    "react-bootstrap": "^1.5.2",
    "react-dom": "^17.0.2",
  }
}
```

next.config.js 

```
module.exports = {
    env: {
        PRIVATE_KEY: process.env.PRIVATE_KEY,
        CLIENT_EMAIL: process.env.CLIENT_EMAIL,
        PROJECT_ID: process.env.PROJECT_ID,
        NEXT_PUBLIC_GA_ID: process.env.NEXT_PUBLIC_GA_ID
    }
  };
```
  

@RealDrewKlayman
Copy link

It seems like you are in the same boat as us.
The Module Not Found is not working correctly.

This is related with #2098.

@IbrahimSam96

@bojidaryovchev
Copy link

yo guys, I think I found a solution. For me, the approach with next.config.js did not work, so after trying various things I saw AWS User Guide # Access Environment Variables and managed to get it working.

  1. I went to my Amplify app Build Settings
  2. I edited the App build specification amplify.yml file
  3. For every Environment Variable I had added in the Amplify app Environment Variables section, I added
    - echo "SOME_VARIABLE=$SOME_VARIABLE" >> .env
  4. That's it, after that I redeployed the build and I had all my variables present

@calavera calavera added the ssr Server Side Rendering feature label Nov 15, 2022
@Jay2113
Copy link
Contributor

Jay2113 commented Mar 7, 2024

This issue is a duplicate of #2098 and it seems isolated to Next v11. We have since launched improved support for Next.js versions 12 and 13 so this should no longer be an issue.

@Jay2113 Jay2113 closed this as not planned Won't fix, can't repro, duplicate, stale Mar 7, 2024
Copy link

github-actions bot commented Mar 7, 2024

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Copy link

github-actions bot commented Mar 7, 2024

This issue has been automatically locked.

@github-actions github-actions bot added the archived This issue has been locked. label Mar 7, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Mar 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived This issue has been locked. question Further information is requested ssr Server Side Rendering feature
Projects
None yet
Development

No branches or pull requests

5 participants