Setting up AWS accounts for AWS Amplify
To secure authentication flows, developers need to implement additional security options to their applications. One of the most common use-cases that serves this purpose is to add an SMS verification/approval flow to the application.
In order to use SMS for verification flows, customers can provide their phone number through the following ways:
- As a username: Users login with a username and password where their phone number acts as the username.
- As a verification method: Users login using a username, email or phone number, but must verify their account with an OTP (one time password) sent to their phone.
- MFA (Multi-Factor Authentication): Users must verify every login with an OTP sent to their phone.
In the span of this blog post series, you will be learning:
- Creating an AWS Account (Current post)
- Setting up Amplify CLI on your machine (Current post)
- Creating a new Flutter project from Flutter CLI tool
- Initializing the AWS Amplify project by using Amplify CLI into your Flutter project
- Implementing a sign up flow with phone number
- Implementing a sign in flow with phone number
- Install the latest Flutter version (or at least 2.10,0+). If you do not have the Flutter setup, follow the instructions over flutter.dev for your operating system.
- Setup your preferred IDE by installing Flutter and Dart plugins. You can check the official documentation for further information.
- Install the below tools for setting up Amplify CLI at later stage
- Node.js v14.x or later
- npm v6.14.4 or later
- git v2.14.1 or later
If you have the requirements ready, you can start!
Creating an AWS Account
For your AWS Amplify or any AWS related applications you are expected to have an AWS account. Go to
aws.amazon.com, and click on the Complete Sign Up button on the top right corner.
That will direct you to a page to login or give you an option to create an AWS account with Create a New AWS Account. Click on the button and start the process of creating AWS Account.
Enter your email address and create a unique account name. After you entered the necessary information, click on the Verify email address button to move forward.
Now you will receive an activation code with your email address. You should enter that in the next page and continue. After verification, you will be directed to the password setting page:
After you setup a password, now you need to enter and submit your profile information:
Once you are done with setting up your personal information, you need to enter a payment method. Please keep in mind that, you will not be charged for anything at this point. $1 will be deducted and then refunded to your account to verify your account.
Afterwards, you are done with adding the payment method. Confirm your identity by entering the verification code that has been sent to the phone number information you have entered.
Once you are done with the confirmation, now it is time to select the account tier that you would like to use.
Continuing with the Free Tier should be sufficient for moving forward with the tutorial.
After that, click on the Complete sign up button and it will take you back to the login page. Login with the account information that you created and reach to the console.
Setting up Amplify CLI on your machine
You can install the Amplify CLI tool with either NPM or cURL. For NPM you can use the following command:
npm install -g @aws-amplify/cli
If you want to use cURL, you can do the following:
#For macOS and other Linux distributions
curl -sL https://aws-amplify.github.io/amplify-cli/install | bash && $SHELL#For Windows
curl -sL https://aws-amplify.github.io/amplify-cli/install-win -o install.cmd && install.cmd
Once you run these commands, it will add the
amplify command globally so you can use it in either new projects or with the projects that you already have.
You now need to setup your AWS account using the Amplify CLI. For that, you need to run the following command in your terminal:
The CLI will direct you to a page to login to the AWS Console. Login to the console if you have not already. Then, go back to the terminal and click on Enter to continue. Once you are signed in, Amplify CLI will ask you to create an IAM user, select the region that is the best for you (For more information about the regions, you can check the Regions and Zones document). After that continue user creation over the AWS Console by adding user details. After that click on next and go to policy screen:
Make sure to select
AdministratorAccess-Amplify as a policy to enable your IAM account to have Admin access over your Amplify projects.
After this step, click on Next buttons until you reach the access information. Do not close these windows and go back to the terminal.
Enter the access key of the newly created user:
? accessKeyId: ********************
? secretAccessKey: ****************************************
Fill the information above by copying and pasting the key and id that you have. Lastly, create a profile on your local machine (you can just click Enter and accept default) and you are done with the setup!
Successfully set up the new user.
For more information about the AWS Amplify authentication libraries you can check the official documentation, ask your questions at Amplify Discord. You can also check the source code for this over GitHub and if you have any questions regarding to the Amplify and Flutter topics, send it to me via DM on Twitter!
See you in the next post!
Follow Flutter Community on Twitter: https://www.twitter.com/FlutterComm