Amplify CLI Cheatsheet

Amplify CLI Cheatsheet

·

6 min read

A list of common commands for using Amplify CLI. Full Docs

Installation

  • Windows:
    curl -sL https://aws-amplify.github.io/amplify-cli/install-win -o install.cmd && install.cmd
    
  • Mac / Unix
    curl -sL https://aws-amplify.github.io/amplify-cli/install | bash && $SHELL
    
  • NPM
    npm install -g @aws-amplify/clinpm install -g @aws-amplify/cli
    

Start First Time Configuration

amplify configure

Commands

Initialize a new Amplify project

amplify init

Clone an Amplify project from github

amplify init --app <github url>

Base Commands

amplify <command> <subcommand>

  init                Initializes a new project, sets up deployment resources in the cloud, and makes your project ready for Amplify.
  configure           Configures the attributes of your project for amplify-cli, such as switching front-end framework and adding/removing cloud-provider plugins.
  push                Provisions cloud resources with the latest local developments.                                    
  pull                Fetch upstream backend environment definition changes from the cloud and updates the local environment to match that definition.
  publish             Executes amplify push, and then builds and publishes client-side application for hosting.         
  serve               Executes amplify push, and then executes the projects start command to test run the client-side application locally.
  status              Shows the state of local resources not yet pushed to the cloud (Create/Update/Delete).            
  delete              Deletes all of the resources tied to the project from the cloud.                                  
  <category> add      Adds a resource for an Amplify category in your local backend                                     
  <category> update   Update resource for an Amplify category in your local backend.                                    
  <category> push     Provisions all cloud resources in a category with the latest local developments.                  
  <category> remove   Removes a resource for an Amplify category in your local backend.                                 
  <category>          Displays subcommands of the specified Amplify category.                                           
  mock                Run mock server for testing categories locally.                                                   
  codegen             Generates GraphQL statements(queries, mutations and eventHandlers) and type annotations.          
  env                 Displays and manages environment related information for your Amplify project.                    
  console             Opens the web console for the selected cloud resource.                                            
  logout              If using temporary cloud provider credentials, this logs out of the account.

Categories

List of Categories

analytics
api
auth
function
hosting
interactions
notifications
predictions
storage       
xr

Category Commands

All categories use these common commands. If they have additional commands, they are listed under "Unique Commands":

amplify <category> <subcommand>

  add       Takes you through a CLI flow to add an resource to your local backend                             
  update    Takes you through steps in the CLI to update a resource                                          
  push      Provisions cloud resources with the latest local developments                                
  remove    Removes resource from your local backend. The resource is removed from the cloud on the next push command.
  console   Opens the web console for the category

Unique Category Commands

API

amplify api <subcommands>
  gql-compile              Compiles your GraphQL schema and generates a corresponding cloudformation template           
  add-graphql-datasource   Provisions the AppSync resources and its dependencies for the provided Aurora Serverless data source

Auth

amplify auth <subcommands>
import    Takes you through a CLI flow to import an existing auth resource to your local backend

Function

amplify function <subcommands>
build    Builds all the functions in the project (does an npm install on the functions src directory)

amplify hosting (managed hosting)

(Managed hosting with custom domains, Continuous deployment)
amplify hosting serve: Opens your deployed site

amplify hosting configure: Set up custom domains, redirects, password protection, and more via the Amplify Console.

amplify publish: Publishes changes to manually deployed apps. For continuous deployment, please push to your git branch to deploy updates.

amplify hosting remove: Remove hosting from you app.

amplify storage

import   Takes you through a CLI flow to import an existing storage resource to your local backend

env

amplify env <subcommands>

  add                                                                              Adds a new environment to your Amplify Project                                                                                                                                     
  pull [--restore]                                                                 Pulls your environment with the current cloud environment. Use the restore flag to overwrite your local backend configs with that of the cloud.                                    
  checkout <env-name> [--restore]                                                  Moves your environment to the environment specified in the command. Use the restore flag to overwrite your local backend configs with the backend configs of the environment specified.
  list [--details] [--json]                                                        Displays a list of all the environments in your Amplify project                                                                                                                    
  get --name <env-name> [--json]                                                   Displays the details of the environment specified in the command                                                                                                                   
  import --name <env-name> --config <provider-configs> [--awsInfo <aws-configs>]   Imports an already existing Amplify project environment stack to your local backend                                                                                                
  remove <env-name>                                                                Removes an environment from the Amplify project