How to update aws amplify auth in an application?
Update AWS Amplify Auth
I am developing applications using ReactJs and AWS Amplify. In a project I need to update amplify auth to add admin queries API. There is a command for this in AWS Amplify CLI that is “amplify auth update“, this will provide workflow of different commands that will require to update auth. To do this, first go into your project directory terminal or powershell (if you are using windows.)
Then run “amplify auth update”. This command will show some options as following.
Select “Walkthrough all the auth configurations” by moving arrow down from keyboard. And press “Enter”. There will be further workflow options after this.
Press enter to select first option, User Sign-up, Sign-in, connect with AWS IAM. From next options, select “No”
From next options, select “No” for 3rd party authentication providers
Next, you will be asked for “User pool group”, if you required or not in your project. Select ‘Yes’ if required. I selected ‘Yes’ as I required groups in my project.
As I already have configured groups so I have following options. I don’t want to delete any group so I just pressed enter to go further.
Next option will ask you for new group. If you want to add new then press “y” otherwise “N”. If you pressed “y” then you will be asked to enter new group.
Next set order for entered groups.
Now, select “yes” or “no” to add admin queries API. I selected “Yes” as I updated amplify auth to add API.
Now in next step add restriction for admin queries API.
Select Off for multi factor authentication in next step, as we don’t this.
Enable email based user sign in and registration.
In next step, setup email verification subject and message.
In next, you can change default password policy.
Setup days for refresh token expiration.
Specify Read/Write attributes.
Enable any of capabilities from following. I will select Add to Group as I need to add user to group after registration.
Next I need to add Lambda Triggers for AWS Cognito, so that user can be added to specific group after confirmation. So, I selected Post Confirmation.
In next step, you will need to specify what functionality you need for Post Confirmation. There will be option “Add User To Group”. Select this.
Admin queries API added in the project for user’s module where user can be add/edit and enabled in AWS Cognito, for this you must have enabled ALLOW_ADMIN_USER_PASSWORD_AUTH option in AWS Cognito APP tab.
Also you might need to update could formation, cognito actions and API files for auto confirmation.
After all this workflow, you will need to run “amplify push” command so that all changes can be pushed to AWS console.
That’s it. Hope this will help.