aws-amplify / amplify-backend

Home to all tools related to Amplify's code-first DX (Gen 2) for building fullstack apps on AWS
Apache License 2.0
140 stars 46 forks source link

Accessing Secrets in Amplify Gen 1 App #1690

Open sph94 opened 1 week ago

sph94 commented 1 week ago

Amplify CLI Version

12.12.3

Question

I am trying to access secrets in my webhook. I am using Amplify Gen 1. I have entered the secrets under amplify > hosting settings > secrets, but I am unable to access them e.g. with process.env.WEBHOOK_SECRET (though accessing environment variables works fine) - but it just returns undefined when I log the secrets.

How can I access these secrets? On the amplify docs all I can see is "In Amplify Gen 1, you need to define environment variables and secrets using the CLI and store keys in both AWS Parameter Store and a local team-provider.json file."

Would be very helpful if there was actually further detail on accessing these. I cant see how I can do this in the CLI nor how the team-provider file should be edited.

Or is using process.env.WEBHOOK_SECRET just the wrong way to access them? If the secrets tab under hosting is just for Gen 2, it really should be specified on the page that this is the case.

ykethan commented 1 week ago

Hey @sph94, thank you for reaching out. The information is currently documented on https://docs.aws.amazon.com/amplify/latest/userguide/environment-variables.html#environment-secrets

Transferring to the backend repository and marking this for improvements.