내용으로 건너뛰기

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.

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.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

관련 콘텐츠