[ aws . amplifygen3 ]

deploy

Description

Deploy your app to an Amplify environment (preview by default). Use –prebuilt to upload output you have already built instead.

If no app with the resolved name exists, the command creates it, along with its IAM roles, before deploying.

The first line of output names the app being deployed to. When there is no config file (amplify.jsonc by default) and no –app, the name comes from package.json or the directory name, so the command says which and asks you to confirm it before deploying. –yes confirms it without asking. In a headless (CI=true) session, where there is nobody to ask, the deploy fails unless –app or –yes is passed.

A source deploy is built in Amplify, so node_modules and the build output directory (deploy.output_directory) are left out of the upload even when .gitignore does not list them. Add a .amplifyignore file (same syntax as .gitignore) to exclude anything else.

For an app with a backend, the deployment runs against one branch of the environment’s backend, and each branch has its own database. Amplify picks the branch: production in the production environment, and source-upload in any other environment. It creates the branch, with a new database, the first time a deploy needs it, including after the branch was deleted with aws amplifygen3 branch delete. To deploy against another branch of the environment that already exists, pass –branch-arn. Only that deployment uses it: the next deploy without –branch-arn goes back to the branch Amplify picks.

Symbolic links that point outside the upload directory are left out with a warning unless you pass –follow-symlinks. A link to a file the upload excludes (for example under .git or node_modules) is always left out. A link to a directory inside the upload directory is uploaded as a copy of that directory; a link to a directory outside it is always left out with a warning.

Once the deployment succeeds, the command reports whether the app’s backend is READY, the branch the deployment ran against and which migrations it applied, then checks for up to a minute that the URL it printed (and the backend’s /health) answers. A 401 or 403 counts as an answer: access control or a firewall rule refuses the check. The check only reports: the exit code is the deployment’s, and it covers only the edge location this machine reaches. Ctrl-C stops the check, not the command.

On an environment with a gradual rollout, a deployment that succeeded does not serve all traffic yet. The output then ends with the aws amplifygen3 deployment get --watch command that follows the rollout, and says whether traffic moves to the new deployment in stages or waits for another deployment that is still rolling out.

With –output or –query, the progress goes to stderr and stdout carries one document: the deployment as aws amplifygen3 deployment get --id <id> --output json shows it, plus Readiness (the backend status and each URL checked, with its Status of SERVING, REFUSED or NOT_SERVING). With –no-wait, it is the created deployment.

Synopsis

  deploy
[--app <value>]
[--env <value>]
[--branch-arn <value>]
[--config <value>]
[--filter <value>]
[--logs]
[--prebuilt <value>]
[--no-wait]
[--allow-destroy]
[--yes]
[--allow-install]
[--create-publishable-key]
[--follow-symlinks]
[--debug]
[--endpoint-url <value>]
[--no-verify-ssl]
[--no-paginate]
[--output <value>]
[--query <value>]
[--profile <value>]
[--region <value>]
[--version <value>]
[--color <value>]
[--no-sign-request]
[--ca-bundle <value>]
[--cli-read-timeout <value>]
[--cli-connect-timeout <value>]
[--cli-binary-format <value>]
[--no-cli-pager]
[--cli-auto-prompt]
[--no-cli-auto-prompt]
[--cli-error-format <value>]
[--help]

Options

--app (string) App name. If omitted, the name is read from the config file (amplify.jsonc by default, see –config), then package.json, then the directory name. Both are looked up in the current directory, or in the –filter directory when –filter is set. Shorthand: -a.

--env (string) Environment to deploy to. Defaults to preview. Shorthand: -e.

--branch-arn (string) Deploy against this branch of the backend instead of the one Amplify picks. Pass the branch ARN that aws amplifygen3 branch get shows, such as arn:aws:amplifygen3:us-east-1:123456789012:app/my-app/environment/preview/branch/feature-x. The branch must belong to the app and the –env environment, and must already exist: Amplify never creates a branch for it. In the production environment only the production branch is accepted. Requires an existing app with a backend, and cannot be combined with –allow-destroy.

--config (string) Path to the configuration file to read the app name and build settings from. Defaults to amplify.jsonc. The path is relative to the current directory, or to the –filter directory when –filter is set. The file is uploaded as amplify.jsonc, in place of any amplify.jsonc in the uploaded files, so the build uses it too; local files are not changed. Shorthand: -c.

--filter (string) Deploy an app that lives in a subdirectory of a monorepo (e.g., apps/web). Files are still uploaded from the current directory (the workspace root), and the build runs from the subdirectory. For an existing app, a subdirectory other than the root directory already stored on the app is refused before anything is uploaded (a deploy can’t change it); change it with aws amplifygen3 app edit --root-dir. Cannot be combined with –prebuilt.

--logs (boolean) Stream the deployment log to the terminal while the deployment runs. Has no effect with –no-wait.

--prebuilt (string) Deploy build output you already built locally, instead of uploading the source and building it in Amplify. Pass a directory (zipped for you) or a zip file, as a path or file:// URI. With no value, uses the directory set in deploy.output_directory in the config file. A node_modules folder inside the directory is always uploaded, even if .gitignore or .amplifyignore excludes it, because dependencies are not reinstalled for a prebuilt deploy. For an app with a backend, a directory upload also carries the migrations folder next to the config file, since build output does not contain it, unless the directory has a migrations folder of its own. A zip file is uploaded as it is, so it needs its own migrations folder at its root.

--no-wait (boolean) Exit as soon as the deployment is created instead of waiting for it to finish. The deployment ID, a console link to monitor it, and the aws amplifygen3 deployment get --watch command that waits for its result are still printed.

--allow-destroy (boolean) Allow the deploy to delete the app’s backend when the cloud app has one but amplify.jsonc no longer declares a backend block. Deleting the backend deletes the database and sign-in users of every environment, production included, whatever –env says, and cannot be undone. The deploy lists what it would delete and asks for confirmation first (pass –yes to skip the prompt). In every other case the flag has no effect and the deploy says so. Without this flag the deploy proceeds normally and the backend is left in place.

--yes (boolean) Confirm without being asked. With no config file (amplify.jsonc by default) and no –app, it confirms the app name taken from package.json or the directory name. With –allow-destroy, it skips the confirmation prompt and deletes the backend immediately. Required for either in a headless (CI=true) session, where there is no prompt to answer: without it the deploy fails before anything is created or uploaded. Shorthand: -y.

--allow-install (boolean) Install the framework adapter without asking. Nuxt, Astro and SvelteKit need an adapter package before the build can write its output directory, and deploy offers to install it when the app does not have it yet. Pass this to accept up front, which is the only way to accept in a headless (CI=true) session, where there is no prompt to answer; without it a headless run prints the steps and the deploy continues. Setting the adapter in the framework config is printed either way, to do by hand. No effect with –prebuilt, which runs no build, or for Next.js, whose adapter is the build command. Named apart from –yes, which confirms the app name and backend deletion.

--create-publishable-key (boolean) Mint a new publishable key for the backend branch and inject it into this deployment instead of reusing the branch’s current key. This is the first half of a key rotation: the new key is what this deployment and every later one carry, while the old key keeps working until you revoke it with aws amplifygen3 backend publishable-key revoke. Revoking first instead would break the running app. Anything holding the old key – a client you ship separately, another service – has to be moved over before you revoke it. An app without a backend has no keys, and passing this flag there makes the service refuse the whole deploy, so only use it on an app with a backend.

--follow-symlinks (boolean) Upload files that symbolic links point to outside the upload directory (the current directory, or the –prebuilt directory), under the name of the link. Without this flag those links are left out with a warning. The files are published at your deployment URL, so use this only for links you trust; each one is listed after the upload. Links to directories outside the upload directory, links whose target is missing, and links to files the upload excludes are always left out. Has no effect when –prebuilt is a zip file.

Global Options

--debug (boolean)

Turn on debug logging.

--endpoint-url (string)

Override command’s default URL with the given URL.

--no-verify-ssl (boolean)

By default, the AWS CLI uses SSL when communicating with AWS services. For each SSL connection, the AWS CLI will verify SSL certificates. This option overrides the default behavior of verifying SSL certificates.

--no-paginate (boolean)

Disable automatic pagination. If automatic pagination is disabled, the AWS CLI will only make one call, for the first page of results.

--output (string)

The formatting style for command output.

  • json
  • text
  • table
  • yaml
  • yaml-stream
  • off

--query (string)

A JMESPath query to use in filtering the response data.

--profile (string)

Use a specific profile from your credential file.

--region (string)

The region to use. Overrides config/env settings.

--version (string)

Display the version of this tool.

--color (string)

Turn on/off color output.

  • on
  • off
  • auto

--no-sign-request (boolean)

Do not sign requests. Credentials will not be loaded if this argument is provided.

--ca-bundle (string)

The CA certificate bundle to use when verifying SSL certificates. Overrides config/env settings.

--cli-read-timeout (int)

The maximum socket read time in seconds. If the value is set to 0, the socket read will be blocking and not timeout. The default value is 60 seconds.

--cli-connect-timeout (int)

The maximum socket connect time in seconds. If the value is set to 0, the socket connect will be blocking and not timeout. The default value is 60 seconds.

--cli-binary-format (string)

The formatting style to be used for binary blobs. The default format is base64. The base64 format expects binary blobs to be provided as a base64 encoded string. The raw-in-base64-out format preserves compatibility with AWS CLI V1 behavior and binary values must be passed literally. When providing contents from a file that map to a binary blob fileb:// will always be treated as binary and use the file contents directly regardless of the cli-binary-format setting. When using file:// the file contents will need to properly formatted for the configured cli-binary-format.

  • base64
  • raw-in-base64-out

--no-cli-pager (boolean)

Disable cli pager for output.

--cli-auto-prompt (boolean)

Automatically prompt for CLI input parameters.

--no-cli-auto-prompt (boolean)

Disable automatically prompt for CLI input parameters.

--cli-error-format (string)

The formatting style for error output. By default, errors are displayed in enhanced format.

  • legacy
  • json
  • yaml
  • text
  • table
  • enhanced

--help (boolean)

Display help for the command/subcommand.

Examples

Note

To use the following examples, you must have the AWS CLI installed and configured. See the Getting started guide in the AWS CLI User Guide for more information.

Unless otherwise stated, all examples have unix-like quotation rules. These examples will need to be adapted to your terminal’s quoting rules. See Using quotation marks with strings in the AWS CLI User Guide .

Example 1: To deploy to the default environment

The following deploy example uploads the current directory and deploys it to the preview environment. The service installs dependencies and runs the build, so node_modules is never uploaded. Files matched by .gitignore or .amplifyignore are excluded.

The deployment ID and host name in the output are fictitious and do not identify live resources.

aws amplifygen3 deploy \
    --app my-app

Output:

Uploading files
Files uploaded in 3.4 seconds

DeploymentID d-abc123xyz created in Environment preview!
  Visit:    https://preview.my-app.example.com
  Monitor:  https://us-west-2.console.aws.amazon.com/amplifygen3/apps/my-app/deployments/preview/d-abc123xyz

Example 2: To deploy to a named environment

The following deploy example deploys to production instead of the default preview environment.

aws amplifygen3 deploy \
    --app my-app \
    --env production

Output:

Uploading files
Files uploaded in 3.6 seconds

DeploymentID d-def456uvw created in Environment production!
  Visit:    https://production.my-app.example.com
  Monitor:  https://us-west-2.console.aws.amazon.com/amplifygen3/apps/my-app/deployments/production/d-def456uvw

To read the logs of a deployment that has already run, use aws amplifygen3 logs get.

Example 3: To deploy a directory you built yourself

The following deploy example uploads an already-built output directory and skips the service-side build. Because nothing reinstalls dependencies on the other side, a prebuilt upload keeps the node_modules the artifact needs at run time, even when .gitignore excludes it.

aws amplifygen3 deploy \
    --app my-app \
    --prebuilt ./.amplify

Output:

Uploading files
Files uploaded in 2.1 seconds
DeploymentID d-ghi789rst created in Environment preview!
  Visit:    https://preview.my-app.example.com
  Monitor:  https://us-west-2.console.aws.amazon.com/amplifygen3/apps/my-app/deployments/preview/d-ghi789rst

Example 4: To upload files that symbolic links point to outside the project

The following deploy example uploads the targets of outside links under the names of the links, and lists each one after the upload. By default, deploy leaves out a symbolic link whose target is outside the upload directory, and prints a warning that lists it. This keeps a committed link such as public/creds -> ~/.aws/credentials from publishing its target. Links whose target is missing, and links to a file the upload excludes (for example public/cfg -> ../.git/config), are also left out with a warning, with or without --follow-symlinks. A link to a directory inside the upload directory is uploaded as a copy of that directory. A link to a directory outside it is left out with a warning, even with --follow-symlinks. Use --follow-symlinks only for links you trust, because the files become reachable at your deployment URL.

aws amplifygen3 deploy \
    --app my-app \
    --follow-symlinks

Output:

Uploading files
Uploaded 1 symlink that points outside the upload directory (--follow-symlinks):
  public/shared.css -> /home/user/design-system/shared.css
Files uploaded in 2.9 seconds

To leave a link out without the warning, add it to .amplifyignore.