You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using NextJS with Amplify Gen 2 and
- created nextjs application via npx create-next-app myapp
- installed all amplify packages via npm create amplify@latest -y
- started the amplify sandbox via npx ampx sandbox
- set two secrets in the AWS Amplify website: Hosting / Secrets (to be used for all branches)
Nothing special about my environment.
Describe the bug
What works:
If I hard code my secrets into the application code everything works perfectly locally (npm run dev) as well as hosted on AWS Amplify Gen 2 (via the deployed URL). I can confirm perfect functionality of the use case (send emails after submitting a contact form) in all environments.
What does not work:
Accessing/using the secrets (created in the AWS website) is not possible in my application code (outside of the /amplify directory).
I created secrets in the AWS Amplify website and want to use them in my NextJS application in
pages/api/contact.ts
Ideally I want to use the secrets in line #5 and #6 - this is outside of the /amplify directory.
Environment information
Describe the bug
What works:
If I hard code my secrets into the application code everything works perfectly locally (npm run dev) as well as hosted on AWS Amplify Gen 2 (via the deployed URL). I can confirm perfect functionality of the use case (send emails after submitting a contact form) in all environments.
What does not work:
Accessing/using the secrets (created in the AWS website) is not possible in my application code (outside of the /amplify directory).
I created secrets in the AWS Amplify website and want to use them in my NextJS application in
pages/api/contact.ts
Ideally I want to use the secrets in line #5 and #6 - this is outside of the /amplify directory.
So far I followed the official documentations:
Access Secrets
Set up a Function
My conclusion so far is, that using secrets only works in the /amplify directory i.e.
accessing secret via secret() function in resource.ts
then assigning the secrets via
env from "$amplify/env/secrets"; in the handler.ts
But I am unable to:
Please advise:
How is the intended use of secrets outside the /amplify directory?
Please provide demo code snippets.
Thank you in advance
Reproduction steps
See screenshots attached.
The text was updated successfully, but these errors were encountered: