CLI commands
This page serves as a reference for commands found in the @aws-amplify/backend-cli
package.
All commands can be prefixed with AWS CLI environment variables to change the AWS account behavior with Amplify (Gen 2) commands.
amplify sandbox
Sandbox enables you to develop your backend alongside your frontend's development server. This command will automatically watch for changes in amplify/
, and redeploy each time you save a file. Run npx amplify sandbox
to deploy to your personal cloud sandbox.
Options
--dir-to-watch
(string) - Directory to watch for file changes. All subdirectories and files will be included.--exclude
(string[]) - An array of paths or glob patterns to ignore. Paths can be relative or absolute and can either be files or directories.--name
(string) - An optional name to distinguish between different sandbox environments. Default is the name in your package.json.--config-out-dir
(string) - A path to a directory where the client config file is written. If not provided, defaults to the working directory of the current process.--config-format
(string) - Format in which the client config file is written (choices:mjs
,json
,json-mobile
,ts
,dart
).--profile
(string) - An AWS profile name.
Usage
1amplify sandbox
Use with an alternate profile
You can use the --profile
flag to run sandbox with an AWS profile other than default
:
1amplify sandbox --profile my-other-profile
Additionally, you can use AWS CLI environment variables to specify a different profile:
1AWS_PROFILE=my-other-profile amplify sandbox
Use with an alternate Region
Use AWS environment variables to deploy to a Region other than your AWS profile's configured Region:
1AWS_REGION=us-west-2 amplify sandbox
Use with mobile applications
For mobile applications, you will need to set the output directory and format of the generated configuration file, specifically amplifyconfiguration.json
:
1# for Android2amplify sandbox --config-format json-mobile --config-out-dir app/src/main/res
1# for Swift/iOS2amplify sandbox --config-format json-mobile
1# for Flutter2amplify sandbox --config-format dart --config-out-dir lib
amplify sandbox delete
Delete your personal cloud sandbox. This should only be used if you have an active cloud sandbox that you opted to not delete when exiting npx amplify sandbox
.
Options
--name
(string) - An optional name to distinguish between different sandbox environments. Default is the name in your package.json.--profile
(string) - An AWS profile name.-y, --yes
(boolean) - Do not ask for confirmation before deleting the sandbox environment.
Usage
1amplify sandbox delete
amplify sandbox secret
Manage backend secrets used with your personal cloud sandbox.
Options
--profile
(string) - An AWS profile name.
Usage
1amplify sandbox secret
Using with an alternate AWS profile
You can use the --profile
flag to run sandbox with an AWS profile other than default
:
1amplify sandbox secret list --profile my-other-profile
Additionally, you can use AWS environment variables to specify a different profile:
1AWS_PROFILE=my-other-profile amplify sandbox secret list
Creating a secret
Create secrets for use with your personal cloud sandbox by using sandbox secret set
:
1amplify sandbox secret set LOGINWITHAMAZON_CLIENT_ID
This is how you configure secrets to be retrieved and used within your backend using secret()
.
Removing a secret
If you want to remove a secret you previously set, use sandbox secret remove
:
1amplify sandbox secret remove LOGINWITHAMAZON_CLIENT_ID
Listing secrets
List all available secrets for your personal sandbox in the default AWS profile and Region:
1amplify sandbox secret list
Get a secret and view its details
You can view an existing secret and its details, such as the current version and when it was last updated:
1amplify sandbox secret get LOGINWITHAMAZON_CLIENT_ID2 name: LOGINWITHAMAZON_CLIENT_ID3 version: 14 value: ****5 lastUpdated: Fri Nov 17 2023 12:00:00 GMT-0800 (Pacific Standard Time)
amplify generate
Generate is not intended to be used standalone; however, it does offer a few subcommands to generate information or code that is supplemental to your frontend development.
Each of the following generate
subcommands require either a CloudFormation stack name or an existing Amplify App ID and corresponding git branch:
1# with CloudFormation stack name2amplify generate <subcommand> --stack <cloudformation-stack-name>
1# with Amplify App ID and git branch2amplify generate <subcommand> --app-id <app-id> --branch <git-branch-name>
amplify generate config
Generate the client configuration file (such as amplifyconfiguration.json
) for your frontend application to consume. This is intended to be used to manually generate a configuration file for an environment other than your personal cloud sandbox. For example, you might use it if you would like to verify something your coworker is seeing in their cloud sandbox, or to demonstrate frontend changes locally using a pre-existing "staging" branch.
Options
In addition to the required options noted in amplify generate
:
--profile
(string) - An AWS profile name.--format
(string) - The format into which the configuration should be exported (choices:mjs
,json
,json-mobile
,ts
,dart
).--out-dir
(string) - A path to the directory where config is written. If not provided, it defaults to the working directory of the current process.
Usage
As mentioned above, you can specify a team member's cloud sandbox CloudFormation stack:
1amplify generate config --stack amplify-nextamplifygen2-josef-sandbox-ca85e1081b
Use with mobile applications
Similar to sandbox
, you can specify an alternate configuration file format by using --format
:
1amplify generate config --stack amplify-nextamplifygen2-josef-sandbox-ca85e1081b --format json-mobile
amplify generate graphql-client-code
Generate GraphQL statements for your frontend application to consume.
amplify generate forms
Generate React form components derived from your backend data models for your frontend application to consume.