View a markdown version of this page

Create and deploy an app - AWS Amplify

Create and deploy an app

Welcome to the new AWS Amplify

Amplify now puts hosting, a Postgres database, and sign-in in one AWS account. Deploy from your terminal or from Git, check every change in a preview first, and roll back in one step if something breaks.

Looking for Amplify Hosting? See the Amplify Hosting User Guide.

In this section, you’ll learn how to create the fundamental unit of Amplify, an app. You can do this in the console or using the CLI.

When you create an app, the name must be unique within your account. Follow these guidelines for naming your app:

  • Use lowercase letters, numbers, and hyphens

  • Keep it concise but descriptive

  • For separate stages, such as staging and production, use one app with environments instead of one app for each stage. For more information, see Create a custom environment.

A deployment is a snapshot of your app released to an environment. For more information, see Use environments for your apps. The code in your app is based on the source code you specify. The environment is based on which environment you select. If you create an environment variable, that is released with the deployment. The endpoint is available on the public internet. You receive a deployment URL that you can share. You can’t change the default amplify.app URL. To serve your app from a domain of your own, add a custom domain. For more information, see Custom domains.

You can view each deployment and the deployment details. These details are the environment variables, source code, and any integrations. If you created a secret environment variable, you will not be able to see it in the console.

When you create an app in the console with Create and Deploy, Amplify also deploys it. aws amplifygen3 create doesn’t deploy, so run aws amplifygen3 deploy to create the first deployment. To make other changes, you must redeploy your app.

Create and deploy an app using the console

When you create an app, you add your source code and Amplify will create an initial deployment to the production environment. At any time, you can change the location of your source code. You can start with code you’ve compiled in your local environment, move that code to GitHub, and redeploy your app using GitHub as your source code.

To create an app, you choose where to deploy the source code of your app.

Deploy from GitHub

When you deploy from GitHub, you let AWS access your source code and deploy your code to an environment.

If you use GitHub, every time you push to a branch in your repository, the app will create a new deployment to either the production or preview environments. You can change this behavior in the environment settings.

To create an app using GitHub from the console:

  1. Sign into the Amplify console at https://us-east-2.console.aws.amazon.com/amplifygen3/home.

  2. For create app, choose Deploy from GitHub.

  3. Install Amplify on your GitHub account. If you choose "All repositories", Amplify will have access to all current and future GitHub repositories owned by your GitHub account. If you choose "Only select repositories", you’ll have to reinstall Amplify for any new repositories you want to deploy with Amplify.

  4. After you install Amplify, choose a repository to deploy using Amplify. You can also enter a repository URL.

  5. For Branch, choose the branch you want to use for your deployment.

    This branch will be your production branch. Any time you push code to that branch, it will trigger a deployment to the production environment. If you push your code to any other branch, it will trigger a deployment on the preview environment.

  6. For App name, enter the name you want to use for your app. This name is not visible to customers.

  7. For Root directory, enter the root directory. Keep the directory as ./ unless you have a reason to change it.

  8. For Framework, Amplify understands the framework based on your code. Keep the value as is, unless you want to change it.

  9. (Optional) If you want to configure optional settings, use the dropdown buttons to configure the optional settings.

    • To change which commands are used to install and build your code. If you aren’t familiar with these commands, don’t change them.

    • To add environment variables, enter them in this section.

    • To configure advanced settings, you can set a specific IAM role to have access to AWS resources during build and runtime. We recommend keeping the default value and letting Amplify create a new role for your app. This role will always have the correct permissions to access the necessary AWS resources during build and runtime.

  10. Choose Create and Deploy.

Deploy from GitLab

When you deploy from GitLab, you let AWS access your source code and deploy your code to an environment.

If you use GitLab, every time you update the source branch you specified in your app, the app will create a new deployment.

To create an app using GitLab from the console:

  1. Sign into the Amplify console at https://us-east-2.console.aws.amazon.com/amplifygen3/home.

  2. For create app, choose Deploy from GitLab.

  3. Install Amplify on your GitLab account.

  4. After you install Amplify, choose a repository to deploy using Amplify. You can also enter a repository URL.

  5. For Branch, choose the branch you want to use for your deployment.

  6. For App name, enter the name you want to use for your app. This name is not visible to customers.

  7. For Root directory, enter the root directory. Keep the directory as ./ unless you have a reason to change it.

  8. For Framework, Amplify understands the framework based on your code. Keep the value as is, unless you want to change it.

  9. (Optional) If you want to configure optional settings, use the dropdown buttons to configure the optional settings.

    • To change which commands are used to install and build your code. If you aren’t familiar with these commands, don’t change them.

    • To add environment variables, enter them in this section.

    • To configure advanced settings, you can set a specific IAM role to have access to AWS resources during build and runtime. We recommend keeping the default value and letting Amplify create a new role for your app. This role will always have the correct permissions to access the necessary AWS resources during build and runtime.

  10. Choose Create and Deploy.

Deploy from code in a local environment

You can also deploy an app without connecting a Git repository by uploading a .zip file of your source code or a prebuilt app. For more information about deploying without Git, see Deploy without Git.

Create and deploy an app using the CLI

The following CLI command creates an app.

aws amplifygen3 create --name my-app

The following CLI command creates an app connected from a GitHub repository.

aws amplifygen3 create --git <git-url>

This detects your framework, creates amplify.jsonc, and creates the app in your AWS account. Build settings are configured in amplify.jsonc:

{ "name": "my-app", "deploy": { "install": "npm ci", "build": "npm run build", "output_directory": "dist" } }
An app with a backend needs a deploy block

If amplify.jsonc has a backend block, aws amplifygen3 create also creates the app’s backend. The file needs a deploy block too, because every app needs a web frontend. Without one, the command stops before it creates anything, so add a deploy block that builds your site and run the command again. For what a backend gives your app, see Amplify backend.

To connect a repository to an existing app, run the following command. Replace <git-url> with the HTTPS URL of your repository and <branch> with the branch for production. The first time that you connect a GitHub repository, the CLI gives you a link to install the Amplify GitHub App on your account.

aws amplifygen3 app edit --git <git-url> --git-branch <branch>

To choose the branches and events that deploy each environment, see Set up continuous deployment from Git.