-
Notifications
You must be signed in to change notification settings - Fork 0
Amplify
As many as you have heard, Amplify serves as the heart of our project. It functions as the host of both backend and frontend code, and it is important that while working on the project we know how to connect and use Amplify.
In this document, we will explain how to correctly connect and set up amplify in our local machine.
-
Have a copy of the project's code on your local machine. In case, you don't already have it installed, you can follow the setting up guide on downloading the project and its dependencies.
-
Open a terminal instance and locate yourself in the directory the project is located in.
Perfect! Now that we have our project and all its dependencies installed we can continue installing the Amplify CLI and setting up our project.
-
Installing Amplify CLI
There are a couple of ways to install the amplify CLI, but for the sake of simplicity, we are going to install it using the Node Package Manager (npm). We can install it by running this command:
npm install -g @aws-amplify/cli
We can make sure the Amplify CLI has been correctly installed by running this command and getting a number printed to the screen.
amplify -v
-
Setting up our Amplify project
Once we have installed the Amplify CLI, we can start setting up our project! Before we do anything, make sure to contact your project manager for the app credentials.
The first step is to connect our local project with our Amplify project. Make sure to run this command inside the amazon-solution directory
amplify pull --appId <APP-ID> --envName <ENV-NAME>
After running this command your terminal will prompt you to enter a name for your local project. It will initially be set to the directory's name.
? Enter a name for the project (AmazonSolutionTC3005)
Type the name of your liking and press enter. After this, it should show you the app's configuration. It should look somewhat like this:
Project information | Name: AmazonSolutionTC3005 | Environment: dev | Default editor: Visual Studio Code | App type: javascript | Javascript framework: none | Source Directory Path: src | Distribution Directory Path: dist | Build Command: npm.cmd run-script build | Start Command: npm.cmd run-script start ? Initialize the project with the above configuration? (Y/n)
Type "Y" or press enter to continue.
Now comes the super important part, authentication. A prompt like this should appear:
? Select the authentication method you want to use: (Use arrow keys) > Amplify Studio AWS profile AWS access keys
Use your arrow keys to select AWS access keys.
Once this choice is selected it will ask you to put in the access keys your project manager provided to you. After entering them, your terminal should look a little bit like this:
? accessKeyId: ******************** ? secretAccessKey: ****************************************
After this amplify will prompt you to select a region.
? region: (Use arrow keys) > us-east-1 us-east-2 us-west-1 us-west-2 eu-north-1 eu-west-1 eu-west-2 (Move up and down to reveal more choices)
Choose us-east-1 and press enter.
When asked what app are you working on, choose:
- synCall
Perfect! Now amplify should start downloading and configuring the cloud project in your local machine.
To be sure the project has been configured correctly and you have the latest version, you can run these two commands:
amplify pull
amplify status
After running
amplify status
, make sure your terminal looks like this, if not contact your project manager.Current Environment: dev ┌──────────┬─────────────────┬───────────┬───────────────────┐ │ Category │ Resource name │ Operation │ Provider plugin │ ├──────────┼─────────────────┼───────────┼───────────────────┤ │ Auth │ syncall9ac295e9 │ Update │ awscloudformation │ ├──────────┼─────────────────┼───────────┼───────────────────┤ │ Api │ synCallapi │ Update │ awscloudformation │ ├──────────┼─────────────────┼───────────┼───────────────────┤ │ Storage │ syncallmain │ Update │ awscloudformation │ └──────────┴─────────────────┴───────────┴───────────────────┘ GraphQL endpoint: https://*****.appsync-api.us-east-1.amazonaws.com/graphql GraphQL API KEY: ***** GraphQL transformer version: 2
If your terminal looks like this congratulations!🥳 You have successfully installed the Amplify CLI and connected it to our amplify project! You can now start performing Amplify commands. Just keep in mind that whatever changes you make to the Amplify project would be reflected in everyone's project.
Any questions, suggestions, or feedback feel free to contact me.