reactjsamazon-web-servicesaws-amplifyaws-secrets-manager

How can I access Amplify Secrets From my React App


I'm writing right now a react app locally, which is deployed to amplify when I push the code. In AWS Amplify Console I have two secrets, which I want to access in my react app code.

I tried to look in the Amplify docs but I found only this:

import { defineAuth, secret } from '@aws-amplify/backend';

export const auth = defineAuth({
  loginWith: {
    email: true,
    externalProviders: {
      facebook: {
        clientId: secret('foo'),
        clientSecret: secret('bar')
      }
    }
  }
});

I installed aws-amplify, but this module doesn't have a backend path, and the imported variables does not exist.

I tried to find the secrets in the AWS secret manager, but I couldn't see my amplify secrets there. Maybe they are stored in a secret manager under different names?

My qtn is: How can I access the amplify secrets through my react code? Is there a way of getting the secrets like environment variables? Something like: process.env.MY_SECRET


Solution

  • Accessing secrets stored in the AWS Systems Manager Parameter Store within your React API routes is currently not supported (please see here and here).