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
However, it's way more confusing that it might look from the first glance.
Frontend build time secrets
Documentation says that secrets created through AWS Amplify Gen2 console are stored under the /amplify/<app-id>/<branch-name>/<secret-name>:
But in reality they are stored under the under the path like /amplify/<app-id>/<branch-name>-branch-<some-unknown-id>/<secret-name>, so amplify is failing to load them in Build Time::
Secrets configured as "for all branches" are created under the documented location /amplify/shared/<app_id>/, but they are not being picked up during the build.
Amplify Application needs IAM service role assigned permissions to do ssm: GetParametersByPath for the arn:<partition>:ssm:<region>:<account_id>:parameter/amplify/<app_id>/. Otherwise you will also see warning like [WARNING]: !Failed to set up process.env.secrets1
All above also applies to the Frontend runtime secrets, but frontend runtime doesn't support env variables and seems you need to write them to the .env file instead3, however that would expose plaintext secret values in downloaded build artifact. And seems there are no other workarounds as of yet:
This has been identified as a feature request. If this feature is important to you, we strongly encourage you to give a 👍 reaction on the request. This helps us prioritize new features most important to you. Thank you!
taraspos
changed the title
Secrets usage is incredibly confusing
Secrets usage is not documented properly and incredible confusing
Nov 8, 2024
taraspos
changed the title
Secrets usage is not documented properly and incredible confusing
Secrets usage is not documented properly and incredibly confusing
Nov 8, 2024
Before opening, please confirm:
Amplify Hosting feature
Build settings, Deployments, Environment variables, SSR
Is your feature request related to a problem? Please describe:
AWS Amplify Gen2 console has secrets section and following documentation page about how to use them:
However, it's way more confusing that it might look from the first glance.
Frontend build time secrets
Documentation says that secrets created through AWS Amplify Gen2 console are stored under the
/amplify/<app-id>/<branch-name>/<secret-name>
:But in reality they are stored under the under the path like
/amplify/<app-id>/<branch-name>-branch-<some-unknown-id>/<secret-name>
, so amplify is failing to load them in Build Time::Secrets configured as "for all branches" are created under the documented location
/amplify/shared/<app_id>/
, but they are not being picked up during the build.Amplify Application needs IAM service role assigned permissions to do
ssm: GetParametersByPath
for thearn:<partition>:ssm:<region>:<account_id>:parameter/amplify/<app_id>/
. Otherwise you will also see warning like[WARNING]: !Failed to set up process.env.secrets
1import { defineAuth, secret } from '@aws-amplify/backend';
but it doesn't explain that this works only for backend applications2See this comment for additional details:
Fronted run time secrets
All above also applies to the Frontend runtime secrets, but frontend runtime doesn't support env variables and seems you need to write them to the .env file instead3, however that would expose plaintext secret values in downloaded build artifact. And seems there are no other workarounds as of yet:
import { defineAuth, secret } from '@aws-amplify/backend';
can't be used from Server Side code2Describe how you'd like this feature to work
Footnotes
https://github.com/aws-amplify/amplify-hosting/issues/3348 ↩
https://github.com/aws-amplify/amplify-backend/issues/1052#issuecomment-1957733738 ↩ ↩2
https://docs.aws.amazon.com/amplify/latest/userguide/ssr-environment-variables.html ↩
The text was updated successfully, but these errors were encountered: