跳至内容

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.

已提问 2 年前996 查看次数
1 回答
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.

AWS
专家
已回答 2 年前
专家
已审核 2 年前
  • 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.

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。