What You Will Learn
- Host a static website using AWS Amplify in the AWS console. AWS Amplify provides fully managed hosting for static websites and web apps. Amplify’s hosting solution leverages Amazon CloudFront and Amazon S3 to deliver your site assets via the AWS content delivery network (CDN).
- Set up continuous deployment: Amplify offers a Git-based workflow with continuous deployment, allowing you to automatically deploy updates to your site on every code commit.
Create and connect repository
To begin this tutorial, you'll need to create and initialize a repository. The easiest way to do this is by using the command create-react-app. Install this package using the following command in your Command Prompt or Terminal.Already have a repository to connect? Skip to step c below.Want to deploy without connecting to a Git provider? Begin by clicking here.
npx create-react-app amplifyapp cd amplifyapp npm start
In this step, you will create a GitHub repository and commit your code to the repository. You will need a GitHub account to complete this step – if you do not have an account, sign up here.
a. Create a new GitHub repo for your app (link)
b. Initialize git and push the application to the new GitHub repo executing the following commands in your command line interface:
git init git remote add origin firstname.lastname@example.org:username/reponame.git git add . git commit -m “initial commit” git push origin master
c. To connect your repository, log in to the Amplify Console and choose Get Started at the top of the page then Get Started under Amplify Hosting.
Connect your GitHub, Bitbucket, GitLab, or AWS CodeCommit repositories. You also have the option of manually uploading your build artifacts without connecting a Git repository (see Manual Deploys). After you authorize the Amplify Console, Amplify fetches an access token from the repository provider, but it doesn’t store the token on the AWS servers. Amplify accesses your repository using deploy keys installed in a specific repository only.
After you connect the repository service provider, choose a repository, and then choose a corresponding branch to build and deploy.
Confirm build settings
For the selected branch, Amplify inspects your repository to automatically detect the sequence of build commands to be executed. Confirm your build settings and click Next.
Save and deploy
Review all of your settings to ensure everything is set up correctly. Choose Save and deploy to deploy your web app to a global content delivery network (CDN). Your front end build typically takes 1 to 2 minutes but can vary based on size of the app.
You have finished the Host a Static Website on AWS tutorial.