Page updated Jan 16, 2024

Commands

Team workflows

Amplify environments help you manage your local and cloud environments to mimic your team workflows. Common tasks include:

  • Manage environments to support development processes (e.g., development, staging, production)
  • Test new features safely
  • Share environments between team members
  • Support team workflows

To display all commands available for a new Amplify project, run the following command from the root directory.

amplify env
1amplify env

Commands overview

CommandDescription
amplify env add [--permissions-boundary <IAM Policy ARN>]Adds a new environment
amplify env pull [--restore]Pulls the current environment from the cloud
amplify env checkout <env-name> [--restore]Switches to the selected environment
amplify env list [--details] [--json]Displays a list of all the environments
amplify env get --name <env-name>Displays the environment details
amplify env update [--permissions-boundary <IAM Policy ARN>]Updates the environment's IAM Permissions Boundary
amplify env import --name <env-name> --config <provider-configs> [--awsInfo <aws-configs>]Imports an environment
amplify env remove <env-name>Removes an environment

Environment CLI commands

Add a new environment

amplify env add
1amplify env add

The add command goes through the following steps:

  • Asks for a name for the new environment
  • Creates IAM role for unauthenticated users
  • Creates IAM role for authenticated users
  • Creates S3 bucket for deployment
  • Creates a new backend environment in AWS Amplify Console to view and manage resources.

Optionally, you can configure an IAM Permissions Boundary for all Amplify-generated roles via the --permissions-boundary parameter. For more information about configuring IAM Permissions Boundary, see IAM Permissions Boundary for Amplify-generated roles.

Pull the environment from the cloud

amplify env pull [--restore]
1amplify env pull [--restore]

Use this command to pull the current environment from the cloud. Add the --restore flag to overwrite your local changes like amplify pull command.

Checkout an environment

amplify env checkout <env-name> [--restore]
1amplify env checkout <env-name> [--restore]

Use this command to checkout the <env-name> environment. Add the --restore flag to overwrite your local changes.

List environments

amplify env list [--details] [--json]
1amplify env list [--details] [--json]

Use this command to list all the environments. Add the --details or --json flags to see more details and format the output. Details include the AWS Region, IAM roles, S3 bucket and stack information.

See the output below for an Amplify project with dev and test environments. The active environment is preceded with an asterisk.

amplify env list
1amplify env list
| Environments | | ------------ | | *dev | | test |
1| Environments |
2| ------------ |
3| *dev |
4| test |

Show environment details

amplify env get --name <env-name>
1amplify env get --name <env-name>

Use this command to list all details for <env-name> environment. Details include the AWS Region, IAM roles, S3 bucket and stack information.

Import an environment

amplify env import --name <env-name> --config <provider-configs> [--awsInfo <aws-configs>]
1amplify env import --name <env-name> --config <provider-configs> [--awsInfo <aws-configs>]

Use this command to import an existing environment. Find below an example of a bash command.

#!/bin/bash set -e IFS='|' AWSCLOUDFORMATIONCONFIG="{\ \"Region\": \"us-east-1\",\ \"DeploymentBucketName\": \"mytestproject-20181106123241-deployment\",\ \"UnauthRoleName\": \"mytestproject-20181106123241-unauthRole\",\ \"StackName\": \"mytestproject-20181106123241\",\ \"StackId\": \"arn:aws:cloudformation:us-east-1:132393967379:stack/mytestproject67-20181106123241/1c03a3e0-e203-11e8-bea9-500c20ff1436\",\ \"AuthRoleName\": \"mytestproject67-20181106123241-authRole\",\ \"UnauthRoleArn\": \"arn:aws:iam::132393967379:role/mytestproject67-20181106123241-unauthRole\",\ \"AuthRoleArn\": \"arn:aws:iam::132393967379:role/mytestproject67-20181106123241-authRole\"\ }" PROVIDER_CONFIG="{\ \"awscloudformation\":$AWSCLOUDFORMATIONCONFIG\ }" AWS_CONFIG="{\ \"configLevel\":\"project\",\ \"useProfile\":true,\ \"profileName\":\"default\"\ }" amplify env import \ --name dev \ --config $PROVIDER_CONFIG \ --awsInfo $AWS_CONFIG \ --yes
1#!/bin/bash
2set -e
3IFS='|'
4
5AWSCLOUDFORMATIONCONFIG="{\
6\"Region\": \"us-east-1\",\
7\"DeploymentBucketName\": \"mytestproject-20181106123241-deployment\",\
8\"UnauthRoleName\": \"mytestproject-20181106123241-unauthRole\",\
9\"StackName\": \"mytestproject-20181106123241\",\
10\"StackId\": \"arn:aws:cloudformation:us-east-1:132393967379:stack/mytestproject67-20181106123241/1c03a3e0-e203-11e8-bea9-500c20ff1436\",\
11\"AuthRoleName\": \"mytestproject67-20181106123241-authRole\",\
12\"UnauthRoleArn\": \"arn:aws:iam::132393967379:role/mytestproject67-20181106123241-unauthRole\",\
13\"AuthRoleArn\": \"arn:aws:iam::132393967379:role/mytestproject67-20181106123241-authRole\"\
14}"
15PROVIDER_CONFIG="{\
16\"awscloudformation\":$AWSCLOUDFORMATIONCONFIG\
17}"
18
19
20AWS_CONFIG="{\
21\"configLevel\":\"project\",\
22\"useProfile\":true,\
23\"profileName\":\"default\"\
24}"
25
26amplify env import \
27--name dev \
28--config $PROVIDER_CONFIG \
29--awsInfo $AWS_CONFIG \
30--yes

You can get the AWSCLOUDFORMATIONCONFIG from the team-provider-info.json file from your existing Amplify project.

Remove an environment

amplify env remove <env-name>
1amplify env remove <env-name>

Use this command to remove an environment. This will remove both the local and the cloud environments including all provisioned services and resources.