AWS Amplify Env Variable not picked up

1

Hello,

I am using Amplify to deploy a Next.js 13.4 app using NextAuth. The project runs perfectly on my local environment. NextAuth requires a secret which I put in Amplify's environment variables, but when I deploy the code, I get a server error and the logs say 'NO SECRET'

preguntada hace un año783 visualizaciones
3 Respuestas
1

Hi - Our recommendation is to not use environment variables to store secrets. Store secrets in an environment secret created using the AWS Systems Manager Parameter Store.

Reference : https://docs.aws.amazon.com/amplify/latest/userguide/environment-variables.html

profile pictureAWS
EXPERTO
respondido hace un año
  • Thank you! I moved all of my env variables as you suggested and still get this in the logs:

    INIT_START Runtime Version: nodejs:16.v15 Runtime Version ARN: arn:aws:lambda:us-east-2::runtime:ce158dcc19c42286fef86a8dfb67e1efd92d0de18828736a00f3698410aabcb3 2023-07-14T14:24:47.439-06:00 LOGS Name: bootstrap State: Subscribed Types: [Platform, Function] 2023-07-14T14:24:48.222-06:00 START RequestId: 682f871d-4492-43c8-8b2f-9479064951e7 Version: $LATEST 2023-07-14T14:24:50.270-06:00 [next-auth][error][NO_SECRET] 2023-07-14T14:24:50.270-06:00 https://next-auth.js.org/errors#no_secret Please define a secret in production. MissingSecret [MissingSecretError]: Please define a secret in production. 2023-07-14T14:24:50.270-06:00 at assertConfig (/var/task/.next/server/chunks/294.js:6938:16) 2023-07-14T14:24:50.270-06:00 at AuthHandler (/var/task/.next/server/chunks/294.js:6480:54) 2023-07-14T14:24:50.270-06:00 at processTicksAndRejections (node:internal/process/task_queues:96:5) 2023-07-14T14:24:50.270-06:00 at async NextAuthRouteHandler (/var/task/.next/server/chunks/294.js:9662:30) 2023-07-14T14:24:50.270-06:00 at async NextAuth._args$ (/var/task/.next/server/chunks/294.js:9696:24) 2023-07-14T14:24:50.270-06:00 at async /var/task/.next/server/chunks/981.js:2702:37 { 2023-07-14T14:24:50.270-06:00 code: 'NO_SECRET' 2023-07-14T14:24:50.270-06:00 } 2023-07-14T14:24:50.319-06:00 REPORT RequestId: 682f871d-4492-43c8-8b2f-9479064951e7 Duration: 2096.26 ms Billed Duration: 20

0

Ok, so I was able to log the env variables from Param Store, so that is not the issue. Is this the best forum on AWS to ask about NextAuth?

respondido hace un año
0

https://docs.aws.amazon.com/amplify/latest/userguide/environment-variables.html#environment-secrets

Access environment secrets Accessing an environment secret during a build is similar to accessing environment variables, except that environment secrets are stored in process.env.secrets as a JSON string.

Make sure to specify the app id and backend app name

George
respondido hace un mes

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas