Accessing Amplify secrets at runtime

0

Hi,

The build and deploy passes because it has access to the process.env.secrets at build time.

However, the code needs access to these are run time, to make the authorized requests using a secret.

In the cloud watch logs it shows that secrets is empty.

How do I resolve this problem?

Thanks.

George
asked 14 days ago126 views
1 Answer
0

If i understand correctly, you should be leveraging either AWS Secrets Manager or AWS Systems Manager Parameter Store to store and retrieve secrets. https://docs.aws.amazon.com/secretsmanager/latest/userguide/integrating_parameterstore.html https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-parameter-store.html

If you are using Systems Manager Parameter Store, make sure you use "SecureString" data type. You need to make sure your app has grant access to Parameter Store.

Both Parameter Store and Secrets Manager provide secure storage and retrieval of sensitive data. The choice between the two services depends on your specific requirements, such as rotation policies, auditing, and integration with other AWS services. you have SDK to retrieve the values in both solutions.

profile pictureAWS
EXPERT
SriniV
answered 14 days ago
profile picture
EXPERT
reviewed 10 hours ago
  • Thanks for your answer. I am deploying a Next.js app on Amplify but require to pass a secret into the Node.js process.env.secrets, as described by 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.'

    I created the secret in the parameter store and had access to process.env.secrets during build, but there is an error at runtime because I still require the secret but it's no longer available.

    Thanks.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions