Manage Cognito Credentials In Amplify Config
I am using the Amplify package in my react client for the AWS Cognito authorization. To achieve that I need to configure the Cognito credentials in my client like in the below image.
The problem is I should not hard code the Cognito credentials because when I run my pipeline in a different environment a new Cognito user pool will be created with different credentials. So client has to fetch the Cognito credentials from some place like aws SSM and the authorization should work.
What is the best way to fetch the Cognito credentials for the client(Amplify configuration)?
From your question I assume you are not provisioning that Cognito within the Amplify application that you are writing. With that assumption I would suggest passing that Cognito pool id via an environment variable of platfrom you are running your build on.
If you are using Amplify Console to build and provision your Amplify application, then you should put the environment variable there (in the Environment Variables section).
However, if you are provisioning Cognito within your Amplify app (if you have done
amplify add auth) that Cognito pool id should be present in the
aws-exports.js file that Amplify generates.
Hope this helps.
- → Import statement and Babel
- → should I choose reactjs+f7 or f7+vue.js?
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → .tsx webpack compile fails: Unexpected token <
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → React Native with visual studio 2015 IDE
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM
- → How do I determine if a new ReactJS session and/or Browser session has started?
- → Alt @decorators in React-Native
- → How to dynamically add class to parent div of focused input field?