export const meta = {
  title: `Commands`,
  description: `Use these Amplify CLI commands to manage a team workflow with multiple environments.`,
};

 
## 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.

```bash
amplify env
```

## Commands overview

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

## Environment CLI commands

### Add a new environment

```bash
amplify 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](https://console.aws.amazon.com/amplify) 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](/cli/usage/permissions-boundary).

### Pull the environment from the cloud

```bash
amplify 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

```bash
amplify env checkout <env-name> [--restore]
```

Use this command to checkout the &lt;env-name&gt; environment. Add the `--restore` flag to overwrite your local changes.

### List environments

```bash
amplify 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.

```bash
amplify env list
```

```console
| Environments |
| ------------ |
| *dev         |
| test         |
```

### Show environment details

```bash
amplify env get --name <env-name>
```

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

### Import an environment

```bash
amplify 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.

```bash
#!/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
 
```

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

### Remove an environment

```bash
amplify 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.
