Amplify Console Ug PDF
Amplify Console Ug PDF
Amazon's trademarks and trade dress may not be used in connection with any product or service that is not
Amazon's, in any manner that is likely to cause confusion among customers, or in any manner that disparages or
discredits Amazon. All other trademarks not owned by Amazon are the property of their respective owners, who may
or may not be affiliated with, connected to, or sponsored by Amazon.
AWS Amplify Console User Guide
Table of Contents
What is the AWS Amplify Console? ...................................................................................................... 1
Get started ................................................................................................................................ 1
Amplify Console Features ............................................................................................................ 1
Modern Web Applications ........................................................................................................... 1
Getting Started .................................................................................................................................. 3
Step 1: Connect Repository ......................................................................................................... 3
Step 2: Confirm Build Settings for the Front End ........................................................................... 4
Step 3: Confirm Build Settings for the Backend ............................................................................. 5
Step 4: Add Environment Variables (Optional) ............................................................................... 6
Step 5: Save and Deploy ............................................................................................................. 6
Next Steps ................................................................................................................................ 7
Getting Started with Fullstack Deployments .......................................................................................... 8
Step 1: Deploy a fullstack sample ................................................................................................ 8
Step 2: Explore the Fullstack App ................................................................................................. 9
Step 3: Add a GraphQL backend ................................................................................................ 11
Next steps: Set up feature branch deployments ........................................................................... 12
Setting Up Custom Domains .............................................................................................................. 13
Adding a Custom Domain Managed in Amazon Route 53 ............................................................... 13
Adding a Custom Domain Managed by a Third-Party DNS Provider ................................................. 14
Adding Subdomains .................................................................................................................. 16
Troubleshooting Guide .............................................................................................................. 17
Technical Terminology ...................................................................................................... 17
How do I verify that my CNAME resolves? ........................................................................... 19
My domain hosted with a third party is stuck in Pending Verification state ............................... 20
My domain hosted with AWS Route53 is stuck in Pending Verification state ............................. 20
CNAMEAlreadyExistsException Error .................................................................................... 21
Connecting to Third-Party Custom Domains ........................................................................................ 22
Connecting to a GoDaddy Domain .............................................................................................. 22
Connecting to a Google Domain ................................................................................................ 25
Configuring Build Settings ................................................................................................................. 26
YML Specification Syntax .......................................................................................................... 26
Branch-Specific Build Settings .................................................................................................... 27
Navigating to a Subfolder ......................................................................................................... 28
Deploying the Backend with Your Front End ................................................................................ 28
Setting the Output Folder ......................................................................................................... 28
Installing Packages as Part of Your Build ..................................................................................... 28
Using a Private npm Registry ..................................................................................................... 29
Installing OS packages .............................................................................................................. 29
Key-value storage for every build ............................................................................................... 29
Disable Automatic builds ........................................................................................................... 29
Feature Branch Deployments ............................................................................................................. 31
Team workflows with Amplify CLI backend environments .............................................................. 31
Feature branch workflow ................................................................................................... 17
GitFlow workflow ............................................................................................................. 37
Per-developer sandbox ...................................................................................................... 37
Pattern-based feature branch deployments ................................................................................. 39
Manual Deploys ............................................................................................................................... 42
Drag and Drop ......................................................................................................................... 42
Amazon S3 or any URL ............................................................................................................. 42
One-click Deploy Button ................................................................................................................... 44
Add 'Deploy to Amplify Console' button to your repository or blog ................................................. 44
End-to-End Testing ........................................................................................................................... 45
Tutorial: Set up end-to-end tests with Cypress ............................................................................. 45
Add tests to your existing Amplify app ....................................................................................... 46
iii
AWS Amplify Console User Guide
iv
AWS Amplify Console User Guide
Get started
AWS Amplify Console supports common Single Page App (SPA) frameworks (e.g. React Angular, Vue.js,
Ionic, Ember), as well as static-site generators like Gatsby, Eleventy Hugo, VuePress, and Jekyll.
Get started
To get started with Amplify Console connect your repository (p. 3) (GitHub, BitBucket, GitLab,
and AWS CodeCommit) to set up continuous deployment. Alternatively, start with one of our fullstack
samples (p. 8). Amplify Console automatically detects the front end build settings along with any
backend functionality provisioned with the Amplify CLI (command-line toolchain for creating serverless
backends).
• Manage production and staging environments for your frontend and backend by connecting new
branches. See feature branch deployments (p. 31).
• Connect your custom domain. If you manage your domain in Amazon Route 53, the Amplify Console
automatically connects the root (yourdomain.com), www subdomains (www.yourdomain.com), and
branch (https://dev.yourdomain.com) subdomains. See custom domains (p. 13).
• Preview changes during code reviews by setting up Pull-Request Previews.
• Improve your app quality with end to end tests. See End-to-End Testing (p. 45).
• Password protect your web app so you can work on new features without making them publicly
accessible. See restricting access (p. 54).
• Set up rewrites and redirects to maintain SEO rankings and route traffic based on your client app
requirements. See redirects (p. 48).
Also:
• Instant cache invalidations ensure your app is updated on every code commit instantly.
• Atomic deployments eliminate maintenance windows by ensuring that the web app is only updated
when the entire deployment has finished. This eliminates scenarios where files fail to upload properly.
• Get screen shots of your app rendered on different mobile devices to pinpoint layout issues.
1
AWS Amplify Console User Guide
Modern Web Applications
every button click or search required a round trip to the server, re-rendering the entire application.
Modern web apps offer a native app-like user experience by serving the app front end, or user interface,
efficiently to browsers as prebuilt HTML/JavaScript files that can then invoke backend functionality
without reloading the page.
Modern web applications functionality is often spread across multiple places--such as databases,
authentication services, front end code running in the browser, and backend business logic, or AWS
Lambda functions, running in the cloud. This makes application deployments complex and time-
consuming as developers need to carefully coordinate deployments across the front end and backend to
avoid partial or failed deployments. The AWS Amplify Console simplifies deployment of the front end
and backend in a single workflow.
2
AWS Amplify Console User Guide
Step 1: Connect Repository
To get started, log in to the Amplify Console and choose Get Started under Deploy.
After you connect the repository service provider, choose a repository, and then choose a corresponding
branch to build and deploy.
3
AWS Amplify Console User Guide
Step 2: Confirm Build Settings for the Front End
Important: Verify that the build commands and build output directory (that is, artifacts > baseDirectory)
is accurate. If you need to modify this information, choose Edit to open the YML editor. You can save
your build settings on our servers, or you can download the YML and add it to the root of your repo (for
monorepos, store the YML at the app's root directory).
4
AWS Amplify Console User Guide
Step 3: Confirm Build Settings for the Backend
To deploy backend functionality using the Amplify CLI during your build, create or reuse an IAM service
role. IAM roles are a secure way to grant the Amplify Console permissions to act on resources in your
account.
Note: The Amplify CLI won't run without an IAM service role enabled.
5
AWS Amplify Console User Guide
Step 4: Add Environment Variables (Optional)
Access the build logs screen by selecting a progress indicator on the branch tile. A build has the following
stages:
1. Provision - Your build environment is set up using a Docker image on a host with 4 vCPU, 7GB
memory. Each build gets its own host instance, ensuring that all resources are securely isolated. The
contents of the Docker file are displayed to ensure that the default image supports your requirements.
2. Build - The build phase consists of three stages: setup (clones repository into container), deploy
backend (runs the Amplify CLI to deploy backend resources), and build front end (builds your front-
end artifacts).
3. Deploy - When the build is complete, all artifacts are deployed to a hosting environment managed
by Amplify. Every deployment is atomic - atomic deployments eliminate maintenance windows by
ensuring that the web app is only updated after the entire deployment has completed.
4. Verify - To verify that your app works correctly, Amplify renders screen shots of the index.html in
multiple device resolutions using Headless Chrome.
6
AWS Amplify Console User Guide
Next Steps
Next Steps
• Add a custom domain to your app (p. 13)
• Manage multiple environments (p. 31)
• Preview pull requests before merging
7
AWS Amplify Console User Guide
Step 1: Deploy a fullstack sample
In this tutorial, we are going to create and deploy a React app which implements a basic authentication
flow for signing up/signing in users as well as protected client side routing using AWS Amplify.
8
AWS Amplify Console User Guide
Step 2: Explore the Fullstack App
Choose the Authentication Starter and Deploy app. You will be asked to connect your GitHub account.
Connecting your GitHub acccount allows the Amplify Console to create a fork of the repository in
your account, deploy the AWS backend services, and build and deploy the frontend. In order to deploy
backend resources to AWS, you will need to create a service role (p. 67).
9
AWS Amplify Console User Guide
Step 2: Explore the Fullstack App
At the end of the build, you will have one frontend environment (the master branch deployed at 'https://
master.appid.amplifyapp.com') and one backend environment named devX. To add a user to your app,
you can either register a user through the deployed frontend, or choose the Authentication tab which
links to the Amazon Cognito UserPool. Create a user and try logging in to your app.
10
AWS Amplify Console User Guide
Step 3: Add a GraphQL backend
2. From the Backend environments tab, choose Edit backend. As a pre-requisite, follow the instructions
to install and configure the Amplify CLI. The Amplify command line toolchain allows you to edit
the backend you just created to add more functionality such as GraphQL/REST APIs, analytics, and
storage. Once the Amplify CLI is configured, copy the amplify pull command to connect to this
backend from your local machine.
3. Add the GraphQL API using the default todo example. Learn more about modeling your backend with
the GraphQL transform.
11
AWS Amplify Console User Guide
Next steps: Set up feature branch deployments
amplify push
Current Environment: devw
5. Visit the Amplify Console to view the added API category. Choosing the API category will allow you to
navigate to the AppSync Console (to write queries or mutations performing CRUD operations), or the
DynamoDB Console (to view your Todo table).
6. Use the Amplify GraphQL client to write frontend code that lists and updates the todos. To deploy the
updates to your frontend, simply commit your code and a new build will be triggered in the Amplify
Console.
12
AWS Amplify Console User Guide
Adding a Custom Domain Managed in Amazon Route 53
https://branch-name.d1m7bkiki6tdw1.amplifyapp.com
When you use a custom domain, users see that your app is hosted from a URL, such as the following:
https://www.awesomedomain.com
The Amplify Console issues an SSL certificate for all domains connected to your app so that all traffic is
secured through HTTPS/2. The SSL certificate generated by Amazon Certificate Manager is valid for 30
days and renews automatically as long as your app is hosted with Amplify.
Topics
• Adding a Custom Domain Managed in Amazon Route 53 (p. 13)
• Adding a Custom Domain Managed by a Third-Party DNS Provider (p. 14)
• Adding Subdomains (p. 16)
• Troubleshooting Guide (p. 17)
1. On the left navigation pane, choose App Settings, Domain management, and then choose Add
domain.
2. In Enter your root domain, enter your root domain (https://awesomedomain.com). As you
start typing, root domains that you manage in Amazon Route 53 appear in the list (https://
awesomedomain.com). Select the domain you want to use and then choose Configure Domain.
13
AWS Amplify Console User Guide
Adding a Custom Domain Managed
by a Third-Party DNS Provider
3. By default, the Amplify Console automatically adds two entries for https://
www.myroute53domain.com and https://myroute53domain.com with a redirect set up from the www
subdomain to the root domain (you can change this by choosing Rewrites and redirects from the left
menu). You can modify the default configuration if you want to add subdomains only, see: Connecting
subdomains (p. 16). Choose Save after configuring your domain.
Note: It can take up to 24 hours for the DNS to propagate and to issue the SSL certificate. For more
information about the status messages, see Associating a Domain.
1. On the left navigation pane, choose App Settings, Domain management, and then choose Add
domain.
2. In Enter your root domain, enter your root domain (https://awesomedomain.com) and then choose
Configure domain. If the domain is registered, a green alert notifies you to proceed as long you are
the owner of the domain. If the domain is available, purchase a domain at Amazon Route 53.
14
AWS Amplify Console User Guide
Adding a Custom Domain Managed
by a Third-Party DNS Provider
3. By default, the Amplify Console adds two entries for https://www.awesomedomain.com and
https://awesomedomain.com with a redirect set up from the www subdomain to the root domain.
You can modify the default configuration if you want to add subdomains only, see: Connecting
subdomains (p. 16). Choose Save after configuring your domain.
4. Because the domain is managed externally you must manually configure your DNS provider (for
example, GoDaddy or Google domains). Choose View DNS records in the alert banner.
5. Update your DNS providers' CNAME and ALIAS records as follows. For GoDaddy and Google Domains,
see the step-by-step instructions in Connecting to Third-Party Custom Domains (p. 22).
a. To generate a SSL certificate for your domain, Amplify Console needs to verify ownership.
Configure a CNAME to point to the validation server. Once Amplify Console validates ownership of
your domain, all traffic will be served using HTTPS/2.
b. Configure CNAME record to point your subdomains (https://*.awesomedomain.com) to the
amplifyapp domain. NOTE: If you have production traffic it is recommended you update your
CNAME record after your domain status shows AVAILABLE.
c. Configure ANAME/ALIAS record to point the root domain (https://awesomedomain.com) to your
amplifyapp domain. ANAME records enable you to point the root of your domain to a hostname.
For DNS providers that do not have ANAME/ALIAS support, we strongly recommend migrating your
DNS to Amazon Route 53.
<problematic>**</problematic>
NOTE: If you have production traffic it is recommended you update your ANAME record after your
domain status shows AVAILABLE.*
15
AWS Amplify Console User Guide
Adding Subdomains
Important: Verification of domain ownership and DNS propagation for third-party domains can take up
to 48 hours. For more information about status messages, see Associating a Domain.
Adding Subdomains
A subdomain is the part of your URL that appears before your domain name (for example,
www.amazon.com or aws.amazon.com).
1. Add a subdomain only: If you already have a production website, you might only want to connect
a subdomain (eg https://alpha.mydomain.com). You can do this by choosing Exclude root and
modifying the subdomain to alpha as shown below.
2. Add a multi-level subdomain: You might want to connect a multi-level subdomain (eg https://
beta.alpha.mydomain.com). You can do this by entering alpha.mydomain.com in the domain search
bar, choosing Exclude root, and modifying the subdomain to beta as shown below.
16
AWS Amplify Console User Guide
Troubleshooting Guide
3. Manage subdomains After adding your domain, you might want to add more subdomains. Choose
Manage subdomains from the Domain management screen and edit your subdomains.
Troubleshooting Guide
This guide will help you troubleshoot issues regarding the setup of a custom domain in the AWS Amplify
Console.
Topics
• Technical Terminology (p. 17)
• How do I verify that my CNAME resolves? (p. 19)
• My domain hosted with a third party is stuck in Pending Verification state (p. 20)
• My domain hosted with AWS Route53 is stuck in Pending Verification state (p. 20)
• CNAMEAlreadyExistsException Error (p. 21)
Technical Terminology
1. CNAME - A CNAME (Canonical Record Name) is a type of DNS record which allows you to mask the
domain for a set of webpages and make them appear as though they are located elsewhere. CNAMES
17
AWS Amplify Console User Guide
Technical Terminology
point a subdomain to a Fully Qualified Domain name (FQDN). For example, we can create a new
CNAME record to map the subdomain www.myawesomesite.com to the FQDN domain branch-
name.d1m7bkiki6tdw1.amplifyapp.com assigned to our App.
2. ANAME - An ANAME record is like a CNAME record, but at the root level. An ANAME will point the root
of your domain to a FQDN. That FQDN will actually point to an IP address.
3. Nameserver - A Nameserver is a server on the internet specialized in handling queries regarding the
location of a domain name's various services. If you have your domain setup in AWS Route53, you will
have a list of nameservers assigned to your domain.
When you create a new domain on the Amplify Console, there are a number of steps which need to
happen before you can view your app via your custom domain.
1. SSL Create - AWS Amplify Console is issuing an SSL certificate for setting up a secure custom domain.
2. SSL Configuration/Verification - Before issuing an SSL certificate, Amplify Console must verify that
you are the owner of the domain. For domains managed by Route53, we will automatic update the
DNS verification record. For domains managed outside of Route53, you will need to manually add the
displayed DNS verification record into your domain’s DNS provider.
3. Domain activation - The domain is successfully verified. For domains managed outside of Route53,
you will need to manually add the CNAME records provided in the console into your domain's DNS
provider.
DNS stands for Domain Name System, and is commonly referred to being a phone book, translating
human-readable names (domains) to computer-friendly addresses (IP Addresses).
When you type https://google.com in the browser, a lookup is done in the DNS provider to find the IP
Address of server which hosts the website.
18
AWS Amplify Console User Guide
How do I verify that my CNAME resolves?
DNS providers contain records of domains and their corresponding IP Addresses. Here are the most
commonly used DNS records.
There are a number of free services on the internet you can use to verify your DNS records. For example,
whatsmydns.net.
The Amplify Console uses a CNAME record to verify that you own your custom domain. If you host your
domain with AWS Route53, verification is done on your behalf. However, if you host your domain with a
Third party, you'll have to manually go into your DNS settings and add a new CNAME record.
When you click search, you should that the results show that your CNAME is resolving correctly.
19
AWS Amplify Console User Guide
My domain hosted with a third party
is stuck in Pending Verification state
Note: If you added or updated your CNAME records a few hours after you
created your app, this will most likely cause your app to get stuck in
the pending verification state. It is important that you update your
CNAME records as soon as you create your custom domain.
Once your app is created in the Amplify Console, your CNAME records are checked every few minutes to
determine if it resolves. If it doesn't resolve after an hour, the check is made every few hours which can
lead to a delay in your domain being ready to use.
Lastly, if you have confirmed that the CNAME records exists, then there might be an issue with your DNS
provider. You can either contact the DNS provider to diagnose why the DNS verification CNAME is not
resolving or migrate your DNS to Route53.
Next, choose Registered domains from the left navigation. Ensure the nameservers on the registered
domain screen match what you copied from the Hosted Zone.
20
AWS Amplify Console User Guide
CNAMEAlreadyExistsException Error
CNAMEAlreadyExistsException Error
This means that one of the hostnames you tried to connect (could be a subdomain, or the apex domain)
is already deployed to another AWS CloudFront distribution. Here's how you can diagnose the issue:
1. Check the AWS CloudFront Console to see if you have this domain deployed to any other distribution.
At a time, you can only have a single CNAME record attached to a one CloudFront distribution.
2. Is this domain connected to a different Amplify App that you own? If so, make sure you are not trying
to reuse one of the hostnames. If you are using www.domain.com on the other app, you cannot use
www.domain.com with this appYou can use other subdomains such as blog.domain.com.
3. If you had this domain successfully connected to another app and then recently (within the last hour)
deleted it, please wait and try again after some time. If you still see this exception after 6 hours,
please contact us at [email protected].
21
AWS Amplify Console User Guide
Connecting to a GoDaddy Domain
3. Add CNAME records to to point your subdomains to the Amplify domain, and another CNAME record
to point to Amazon Certificate Manager's validation server. A single validated ACM generates an SSL
certificate for your domain. Make sure you only enter the subdomain (for example, ) in **Host* as
shown below (don't enter yourdomainname.com).
GoDaddy doesn't support ANAME/ALIAS records. For DNS providers that don't have ANAME/ALIAS
support, we strongly recommend migrating your DNS to Amazon Route 53. If you want to keep your
22
AWS Amplify Console User Guide
Connecting to a GoDaddy Domain
current provider and update the root domain, add Forwarding and set up a domain forward. In Forward
to, enter the information as shown following:
23
AWS Amplify Console User Guide
Connecting to a GoDaddy Domain
24
AWS Amplify Console User Guide
Connecting to a Google Domain
3. In Custom resource records, enter CNAME records that you want to point all subdomains (https://
*.awesomedomain.com) to the amplifyapp domain, and another CNAME record to point to Amazon
Certificate Manager's validation server. A single validated ACM generates an SSL certificate for your
domain.
Google domains don't support ANAME/ALIAS records. For DNS providers that don't have ANAME/
ALIAS support, we strongly recommend migrating your DNS to Amazon Route 53. If you want to keep
your current provider and update the root domain, add a Synthetic Record, and set up a Subdomain
Forward. In Subdomain, enter the @ symbol and then choose Forward path as shown following:
25
AWS Amplify Console User Guide
YML Specification Syntax
• Save the build settings in the Amplify Console - The Amplify Console autodetects build settings and
saves it so that they can be accessed via the Amplify Console. These settings are applied to all of your
branches unless there is a YML file found in your repository.
• Save the build settings in your repository - Download the amplify.yml file and add it to the root of
your repository (or root of the app folder for monorepos).
You can edit these settings in the Amplify Console by choosing App Settings>Build settings. These build
settings are applied to all the branches in your app, except for the branches that have a YML file saved in
the repository.
version: 1.0
env:
variables:
key: value
backend:
phases:
preBuild:
commands:
- *enter command*
build:
commands:
- *enter command*
postBuild:
commands:
- *enter command*
frontend:
phases:
preBuild:
commands:
- cd react-app
- npm ci
build:
commands:
- npm run build
artifacts:
files:
- location
- location
discard-paths: yes
baseDirectory: location
cache:
paths:
- path
- path
26
AWS Amplify Console User Guide
Branch-Specific Build Settings
customHeaders:
- pattern: 'file-pattern'
headers:
- key: 'custom-header-name'
value: 'custom-header-value'
- key: 'custom-header-name'
value: 'custom-header-value'
test:
phases:
preTest:
commands:
- *enter command*
test:
commands:
- *enter command*
postTest:
commands:
- *enter command*
artifacts:
files:
- location
- location
configFilePath: *location*
baseDirectory: *location*
frontend:
phases:
build:
commands:
- if [ "${AWS_BRANCH}" = "master" ]; then echo "master branch"; fi
- if [ "${AWS_BRANCH}" = "dev" ]; then echo "dev branch"; fi
27
AWS Amplify Console User Guide
Navigating to a Subfolder
Navigating to a Subfolder
For monorepos, users want to be able to cd into a folder to run the build. After you run the cd command,
it applies to all stages of your build so you don't need to repeat the command in separate phases.
version: 1.0
env:
variables:
key: value
frontend:
phases:
preBuild:
commands:
- cd react-app
- npm ci
build:
commands:
- npm run build
version: 1.0
env:
variables:
key: value
backend:
phases:
build:
commands:
- amplifyPush --simple
frontend:
phases:
commands:
build:
- yarn run build
artifacts:
baseDirectory: public
frontend:
28
AWS Amplify Console User Guide
Using a Private npm Registry
phases:
build:
commands:
- npm install -g pkg-foo
- pkg-foo deploy
- yarn run build
artifacts:
baseDirectory: public
build:
phases:
preBuild:
commands:
- npm config set <key> <value>
- npm config set registry https://registry.npmjs.org
- npm config set always-auth true
- npm config set email [email protected]
- yarn install
Installing OS packages
You can install OS packages for missing dependencies.
build:
phases:
preBuild:
commands:
- yum install -y <package>
Example usage:
29
AWS Amplify Console User Guide
Disable Automatic builds
and then choose Action > Disable auto build. Further commits to that branch will no longer trigger a
new build.
30
AWS Amplify Console User Guide
Team workflows with Amplify CLI backend environments
Your app now has two deployments available at https://master.appid.amplifyapp.com and https://
dev.appid.amplifyapp.com. This may vary from team-to-team, but typically the master branch tracks
release code and is your production branch. The develop branch is used as an integration branch to test
new features. This way beta testers can test unreleased features on the develop branch deployment,
without affecting any of the production end users on the master branch deployment.
Topics
• Team workflows with Amplify CLI backend environments (p. 31)
• Pattern-based feature branch deployments (p. 39)
31
AWS Amplify Console User Guide
Feature branch workflow
You can use the Amplify Console to continuously deploy backend resources such as GraphQL APIs and
Lambda functions with your feature branch deployment. You can use the following models to deploy
your backend and frontend with the Amplify Console:
Topics
• Feature branch workflow (p. 17)
• GitFlow workflow (p. 37)
• Per-developer sandbox (p. 37)
2. Initialize a prod backend environment for your project. If you don't have a project, create one using
bootstrap tools like create-react-app or Gatsby.
create-react-app next-unicorn
cd next-unicorn
amplify init
? Do you want to use an existing environment? (Y/n): n
? Enter a name for the environment: prod
...
amplify push
32
AWS Amplify Console User Guide
Feature branch workflow
4. Push code to a Git repository of your choice (in this example we'll assume you pushed to master).
5. Visit the Amplify Console in the AWS Console to see your current backend environment. Navigate
a level up from the breadcrumb to view a list of all backend environments created in the Backend
environments tab.
33
AWS Amplify Console User Guide
Feature branch workflow
6. Switch to the Frontend environments tab and connect your repository provider and master branch.
34
AWS Amplify Console User Guide
Feature branch workflow
7. In the build settings screen, pick an existing backend environment to set up continuous deployment
with the master branch. Choose prod from the dropdown and grant the service role to Amplify
Console. Choose Save and deploy. After the build completes you will get a master branch deployment
available at https://master.appid.amplifyapp.com.
8. Connect develop branch in Amplify Console (assume develop and master branch are the same at this
point). Choose the test backend environment.
35
AWS Amplify Console User Guide
Feature branch workflow
9. The Amplify Console is now setup. You can start working on new features in a feature branch. Add
backend functionality by using the dev backend environment from your local workstation.
1. After you finish working on the feature, commit your code, create a pull request to review internally.
2. To preview what the changes will look like, go to the Console and connect your feature branch. Note:
If you have the AWS CLI installed on your system (Not the Amplify CLI), you can connect a branch
directly from your terminal. You can find your appid by going to App settings > General > AppARN:
arn:aws:amplify:<region>:<region>:apps/<appid>
4. This will kickoff a build that will update the backend as well as the frontend in the Amplify Console
with a branch deployment at https://dev.appid.amplifyapp.com. You can share this link with internal
stakeholders so they can review the new feature.
36
AWS Amplify Console User Guide
GitFlow workflow
5. Delete your feature branch from Git, Amplify Console, and remove the backend environment from the
cloud (you can always spin up a new one based on by running 'amplify env checkout prod' and running
'amplify env add').
GitFlow workflow
GitFlow uses two branches to record the history of the project. The master branch tracks release code
only, and the develop branch is used as an integration branch for new features. GitFlow simplifies parallel
development by isolating new development from completed work. New development (such as features
and non-emergency bug fixes) is done in feature branches. When the developer is satisfied that the code
is ready for release, the feature branch is merged back into the integration develop branch. The only
commits to the master branch are merges from release branches and hotfix branches (to fix emergency
bugs).
The diagram below shows a recommended setup with GitFlow. You can follow the same process as
described in the feature branch workflow section above.
Per-developer sandbox
• Each developer in a team creates a sandbox environment in the cloud that is separate from their local
computer. This allows developers to work in isolation from each other without overwriting other team
members' changes.
• Each branch in the Amplify Console has its own backend. This ensures that the Amplify Console uses
the Git repository as a single source of truth from which to deploy changes, rather than relying on
developers on the team to manually push their backend or front end to production from their local
computers.
37
AWS Amplify Console User Guide
Per-developer sandbox
2. Initialize a kita backend environment for your project. If you don't have a project, create one using
bootstrap tools like create-react-app or Gatsby.
cd next-unicorn
amplify init
? Do you want to use an existing environment? (Y/n): n
? Enter a name for the environment: kita
...
amplify push
1. Push code to a Git repository of your choice (in this example we'll assume you pushed to master).
38
AWS Amplify Console User Guide
Pattern-based feature branch deployments
3. The Amplify Console will detect backend environments created by the Amplify CLI. Choose Create
new environment from the dropdown and grant the service role to Amplify Console. Choose Save
and deploy. After the build completes you will get a master branch deployment available at https://
master.appid.amplifyapp.com with a new backend environment that is linked to the branch.
4. Connect develop branch in Amplify Console (assume develop and master branch are the same at this
point) and choose Create new environment. After the build completes you will get a develop branch
deployment available at https://develop.appid.amplifyapp.com with a new backend environment that
is linked to the branch.
39
AWS Amplify Console User Guide
Pattern-based feature branch deployments
40
AWS Amplify Console User Guide
Pattern-based feature branch deployments
41
AWS Amplify Console User Guide
Drag and Drop
Manual Deploys
Manual deploys allows you to publish your web app to the Amplify Console without connecting a Git
provider. You can choose to drag and drop a folder from your desktop, or reference an Amazon S3 bucket
or external URL.
For Amazon S3, choose the bucket and zip file to deploy your site. You can also set up AWS Lambda
triggers so your site is updated everytime new assets are uploaded. This blog post walks through setting
up a Lambda trigger to automatically deploy changes to Amplify on any updates to a bucket.
42
AWS Amplify Console User Guide
Amazon S3 or any URL
43
AWS Amplify Console User Guide
Add 'Deploy to Amplify Console'
button to your repository or blog
[](https://
console.aws.amazon.com/amplify/home✔/deploy?repo=https://github.com/username/repository)
<a href="https://console.aws.amazon.com/amplify/home✔/deploy?repo=https://github.com/
username/repository">
<img src="https://oneclick.amplifyapp.com/button.svg" alt="Deploy to Amplify Console">
</a>
44
AWS Amplify Console User Guide
Tutorial: Set up end-to-end tests with Cypress
45
AWS Amplify Console User Guide
Add tests to your existing Amplify app
test:
phases:
preTest:
commands:
- npm install
- npm install wait-on
- npm install [email protected] mochawesome mochawesome-merge mochawesome-report-
generator
- 'npm start & npx wait-on http://localhost:8080'
test:
commands:
- 'npx cypress run --reporter mochawesome --reporter-options "reportDir=cypress/
report/mochawesome-report,overwrite=false,html=false,json=true,timestamp=mmddyyyy_HHMMss"'
postTest:
commands:
- npx mochawesome-merge --reportDir cypress/report/mochawesome-report > cypress/
report/mochawesome.json
artifacts:
baseDirectory: cypress
configFilePath: '**/mochawesome.json'
files:
- '**/*.png'
- '**/*.mp4'
• preTest - Install all the dependencies required to run Cypress tests. Amplify Console uses
<problematic>`mochaawesome <https://github.com/adamgruber/mochawesome`__</problematic>
to generate a report to view your test results and wait-on to set up the localhost server during the
build.
• test - Run cypress commands to execute tests using mochawesome.
• postTest - The mochawesome report is generated from the output JSON.
• artifacts>baseDirectory - The directory from which tests are run.
• artifacts>files - The generated artifacts (screenshots and videos) available for download.
Disabling tests
Once the "test" config has been added to your amplify.yml build settings, the test step will be executed
for every build, on every branch. If you would like to globally disable tests from running, or you would
only like tests to run for specific branches, you can use the "USER_DISABLE_TESTS" environment variable
to do so without modifying your build settings.
To globally disable tests for all branches, add the USER_DISABLE_TESTS environment variable with a
value of true for all branches, as shown below:
46
AWS Amplify Console User Guide
Disabling tests
To disable tests for a specific branch, add the USER_DISABLE_TESTS environment variable with a value
of false for all branches, and then add an override for each branch you would like to disable with a value
of true. In the following example, tests are disabled on the "master" branch, and enabled for every other
branch:
Disabling tests with this variable will cause the test step to be skipped altogether during a build. To re-
enable tests, set this value to false, or delete the environment variable.
47
AWS Amplify Console User Guide
Types of Redirects
Using Redirects
Redirects enable a web server to reroute navigation from one URL to another. Common reasons for
using redirects include: to customize the appearance of URL, to avoid broken links, to move the hosting
location of an app or site without changing its address, and to change a requested URL to the form
needed by a web app.
Types of Redirects
There are several types of redirects that support specific scenarios.
301 redirects are intended for lasting changes to the destination of a web address. Search engine ranking
history of the original address applies to the new destination address. Redirection occurs on the client-
side, so a browser navigation bar shows the destination address after redirection. Common reasons to
use 301 redirects include:
302 redirects are intended for temporary changes to the destination of a web address. Search engine
ranking history of the original address doesn't apply to the new destination address. Redirection occurs
on the client-side, so a browser navigation bar shows the destination address after redirection. Common
reasons to use 302 redirects include:
Rewrite (200)
200 redirects (rewrites) are intended to show content from the destination address as if it were served
from the original address. Search engine ranking history continues to apply to the original address.
Redirection occurs on the server-side, so a browser navigation bar shows the original address after
redirection. Common reasons to use 200 redirects include:
• To redirect an entire site to a new hosting location without changing the address of the site.
• To redirect all traffic to a single page web app (SPA) to its index.html page for handling by a client-side
router function.
404 redirects occur when a request points to an address that doesn't exist. The destination page of a 404
is displayed instead of the requested one. Common reasons a 404 redirect occurs include:
48
AWS Amplify Console User Guide
Parts of a Redirect
Parts of a Redirect
Redirects consist of the following:
To create and edit redirects, choose Rewrites and redirects settings in the left navigation pane.
Order of Redirects
Redirects are executed from the top of the list down. Make sure that your ordering has the effect you
intend. For example, the following order of redirects causes all requests for a given path under /docs/ to
redirect to the same path under /documents/, except /docs/specific-filename.html which redirects to /
documents/different-filename.html:
/docs/<*> /documents/<*>
/docs/specific-filename.html /documents/diferent-filename.html 301
49
AWS Amplify Console User Guide
Simple Redirects and Rewrites
You can use the following example code to permanently redirect a specific page to a new address.
You can use the following example code to redirect any path under a folder to the same path under a
different folder.
You can use the following example code to redirect all traffic to index.html as a rewrite. In this scenario,
the rewrite makes it appear to the user that they have arrived at the original address.
You can use the following example code to use a rewrite to change the subdomain that appears to the
user.
You can use the following example code to redirect paths under a folder that can't be found to a custom
404 page.
50
AWS Amplify Console User Guide
Redirects for Single Page Web Apps (SPA)
51
AWS Amplify Console User Guide
Placeholders
Placeholders
You can use the following example code to redirect paths in a folder structure to a matching structure in
another folder.
You can use the following example code to redirect all paths that can't be found at a given level of a
folder structure to index.html in a specified folder.
Region-based Redirects
You can use the following example code to redirect requests based on region.
52
AWS Amplify Console User Guide
Region-based Redirects
53
AWS Amplify Console User Guide
Restricting access
Working on unreleased features? Password protect feature branches that are not ready to be accessed
publicly.
54
AWS Amplify Console User Guide
Setting Environment Variables
Environment Variables
Environment variables are key-value pairs that are available at build time. These configurations can be
anything, including:
As a best practice, you can use environment variables to expose these configurations. All environment
variables that you add are encrypted to prevent rogue access so you can use them to store secret
information.
If you need to customize a variable specifically for a branch, you can add a branch override. To do this,
choose Actions and then choose Add variable override. You now have a set of environment variables
specific to your branch.
55
AWS Amplify Console User Guide
Accessing Environment Variables
1. In the Amplify console, choose App Settings, choose Build settings, and then choose Edit.
2. Add the environment variable to your build command. You should now be able to access your
environment variable during your next build.
build:
commands:
- npm run build:$BUILD_ENV
56
AWS Amplify Console User Guide
Amplify Console Environment Variables
57
AWS Amplify Console User Guide
Example: Security Headers
Custom Headers
Custom HTTP headers allow you to specify headers for every HTTP response. Response headers can be
used for debugging, security, and informational purposes. Define custom header rules for your app as
follows:
1. From the navigation bar on the left, choose App Settings > Build Settings, and then choose Edit to edit
your buildspec.
2. In the frontend section of the YML file, add the custom headers for your app as follows:
version: 0.1
frontend:
phases:
build:
post_build:
artifacts:
baseDirectory:
customHeaders:
- pattern: '*.json'
headers:
- key: 'custom-header-name-1'
value: 'custom-header-value-1'
- key: 'custom-header-name-2'
value: 'custom-header-value-2'
- pattern: '/path/*'
headers:
- key: 'custom-header-name-1'
value: 'custom-header-value-2'
• pattern - Headers applied to all URL file paths that match the pattern.
• headers - Define headers that match the file pattern. The key is the custom header name and the
value is the custom header value.
• To learn more about HTTP headers, please see Mozilla's documentation for a list of HTTP headers.
1. Choose Save. Your custom header settings will now be applied to your app.
customHeaders:
- pattern: '**/*'
headers:
- key: 'Strict-Transport-Security'
value: 'max-age=31536000; includeSubDomains'
- key: 'X-Frame-Options'
value: 'SAMEORIGIN'
- key: 'X-XSS-Protection'
value: '1; mode=block'
- key: 'X-Content-Type-Options'
58
AWS Amplify Console User Guide
Example: Security Headers
value: 'nosniff'
- key: 'Content-Security-Policy'
value: 'default-src self'
59
AWS Amplify Console User Guide
Incoming Webhooks
Set up an incoming webhook in the Amplify Console to trigger a build without comitting code to your Git
repository. Webhook triggers can be used with headless CMS tools (such as Contentful or GraphCMS) to
trigger builds on content changes, or to trigger daily builds using services such as Zapier.
4. You can copy the webhook URL or run a curl command in your command line to trigger a new build.
60
AWS Amplify Console User Guide
61
AWS Amplify Console User Guide
Analyzing access logs
Access logs
Access logs store information about all requests that are made to your Amplify hosted app. All sites
hosted on Amplify Console have logs retrievable for any two week window. To view access logs choose
App settings > Access logs from your app's left navigation bar. Choose Edit time range to choose the
two week interval you wish to access. The logs are availble to download in a CSV format.
62
AWS Amplify Console User Guide
Custom Build Images
63
AWS Amplify Console User Guide
Custom Build Image Requirements
1. cURL: When we launch your custom image, we download our build runner into your container, and
therefore we require cURL to be present. If this dependency is missing, the build will instantly fail
without any output as our build-runner was unable to produce any output.
2. Git: In order to clone your Git repository we require Git to be installed in the image. If this dependency
is missing, the ‘Cloning repository’ step will fail.
3. OpenSSH: In order to securely clone your repository we require OpenSSH to set up the SSH key
temporarily during the build, the OpenSSH package provides the commands that the build runner
requires to do this.
4. (NPM-based builds)Node.JS+NPM: Our build runner does not install Node, but instead relies on Node
and NPM being installed in the image. This is only required for builds that require NPM packages or
Node specific commands.
64
AWS Amplify Console User Guide
Configuring Live Updates
3. Select a package you’d like to change from the Add package version override list.
4. Input either a specific version of this dependency, or keep the default (latest). If latest is used, the
dependency will always be upgraded to the latest version available. Choose Save to apply the settings.
65
AWS Amplify Console User Guide
Use AWS CloudFormation templates to provision Amplify Console resources, enabling repeatable and
reliable web app deployments. CloudFormation provides a common language for you to describe and
provision all the infrastructure resources in your cloud environment and simplifies the roll out across
multiple AWS accounts and/or regions with just a couple of clicks.
66
AWS Amplify Console User Guide
Step 1: Login to the IAM Console
67
AWS Amplify Console User Guide
Step 3: Return to the Amplify Console
If you already have an existing app, you can find the service role setting in App settings > General and
then choose Edit from the top right corner of the box. Pick the service role you just created from the
dropdown and choose Save.
68
AWS Amplify Console User Guide
Learn more about how the Amplify Console handles cache invalidations.
69