Build a Unique Domain Hosting Environment with AWS Amplify
Tags: amplify, amplifyconsole, route53, aws
Published: 2022-02-21 10:47:59

![img](https://day-journal.com/memo/images/try-083_01.png)

### I built a unique domain hosting environment with AWS Amplify :tada:  

<br>

In my previous article, "[Build a Unique Domain Hosting Environment with Amazon Route 53, AWS WAF, Amazon CloudFront, and Amazon S3](https://dev.to/aws-builders/build-a-unique-domain-hosting-environment-with-amazon-route-53-aws-waf-amazon-cloudfront-and-amazon-s3-5eip)", I tried to implement the contents of that article with AWS Amplify.

<br>

This article will show you how to build three unique domain hosting environment patterns.

#### How to build

1. Build a unique domain hosting environment from AWS console
   - Publish using GitHub with Amplify Console
   - Set up a unique domain with Amplify Console
2. Build a unique domain hosting environment from Amplify CLI
   - Publish using GitHub with Amplify Console(Amplify CLI)
   - Set up a unique domain with Amplify Console
3. Custom hosting environment for a unique domain built from Amplify CLI
   - Custom publishing(Amplify CLI)

# Build a Unique Domain Hosting Environment from the AWS Console

First, we will build a unique domain hosting environment from the AWS console using the Amplify Console.

This hosting environment is designed to be automatically built and deployed in conjunction with GitHub. Although it is not shown on the console, Amazon S3 and Amazon CloudFront are used internally for deployment. Also, it appears that AWS WAF cannot be configured additionally.

## Publishing Using GitHub with Amplify Console

This is how to publish using GitHub with the Amplify Console.

Advance Preparation

- Create a repository on GitHub and reflect your code
- Add a Vue.js project as a sample 

![img](https://day-journal.com/memo/images/aws-amplify-014_01.png)

Click AWS Console → AWS Amplify.
![img](https://day-journal.com/memo/images/aws-amplify-007_01.png)

Click "Start using" under Amplify Hosting.
![img](https://day-journal.com/memo/images/aws-amplify-007_02.png)

Click on "GitHub."
![img](https://day-journal.com/memo/images/aws-amplify-014_02.png)

Click "Authorize" when the GitHub authentication screen appears.
![img](https://day-journal.com/memo/images/aws-amplify-014_03.png)

Select the repository and branch you have prepared in advance. → Click "Next."
![img](https://day-journal.com/memo/images/aws-amplify-014_04.png)

Set an arbitrary application name, and click "Next."
![img](https://day-journal.com/memo/images/aws-amplify-014_05.png)

Click "Save and Deploy."
![img](https://day-journal.com/memo/images/aws-amplify-014_06.png)

A URL will be issued in the AWS console when the automatic deployment is finished, so access it.
![img](https://day-journal.com/memo/images/aws-amplify-014_07.png)

The deployed WebSite will be displayed.

<br>

## Set Up a Unique Domain with Amplify Console

This is how to set up a unique domain with the Amplify Console. 

Advance Preparation

- Get a unique domain using Amazon Route 53

[Amazon Route 53 #001 - Purchase and register your domain name](https://day-journal.com/memo/amazon-route53-001)

![img](https://day-journal.com/memo/images/amazon-route53-001_08.png)

Click on "Manage Domains."
![img](https://day-journal.com/memo/images/aws-amplify-013_01.png)

Click on "Add Domain."
![img](https://day-journal.com/memo/images/aws-amplify-013_02.png)

Select the target domain → Click "Configure Domain."
![img](https://day-journal.com/memo/images/aws-amplify-013_03.png)

Confirm the target domain and branch → Click "Save."
![img](https://day-journal.com/memo/images/aws-amplify-013_04.png)

After the settings are complete, access a unique domain.
![img](https://day-journal.com/memo/images/aws-amplify-013_05.png)

Your website will appear on your domain.
![img](https://day-journal.com/memo/images/aws-amplify-013_06.png)

<br>

# Build a Unique Domain Hosting Environment from Amplify CLI

The next step is to build a unique domain hosting environment from the Amplify CLI using the Amplify Console.

This will be the same hosting environment as described in "Publishing using GitHub with Amplify Console."

## Publish Using GitHub with Amplify Console (Amplify CLI)

This is how to use Amplify CLI to publish using GitHub on Amplify Console.

Advance Preparation

- Build AWS Amplify environment

[AWS Amplify #002 - Building Environment [Vue.js Version]](https://day-journal.com/memo/aws-amplify-002)

Execution environment

- node v16.10.0
- npm v7.24.0

Set up the hosting environment. Select "Hosting with Amplify Console" and "Continuous deployment (Git-based deployments)" at runtime.

```shell
amplify add hosting
```
![img](https://day-journal.com/memo/images/aws-amplify-015_01.png)

The AWS console will automatically appear. Click on "GitHub."
![img](https://day-journal.com/memo/images/aws-amplify-015_02.png)

Click "Authorize" when the GitHub authentication screen appears.
![img](https://day-journal.com/memo/images/aws-amplify-014_03.png)

Select the target repository and branch you prepared in advance → Click "Next."
![img](https://day-journal.com/memo/images/aws-amplify-015_03.png)

Select the target application and environment. If there is no existing role, click "Create New Role."
![img](https://day-journal.com/memo/images/aws-amplify-015_04.png)

Select "AWS Service" as the entity type. Select "Amplify" as the use case → Click "Next."
![img](https://day-journal.com/memo/images/aws-amplify-015_05.png)

Click "Next."
![img](https://day-journal.com/memo/images/aws-amplify-015_06.png)

Set any role name → Click "Create Role."
![img](https://day-journal.com/memo/images/aws-amplify-015_07.png)

Select the role you created → Click "Next."
![img](https://day-journal.com/memo/images/aws-amplify-015_08.png)

Click "Save and Deploy."
![img](https://day-journal.com/memo/images/aws-amplify-015_09.png)

After completing the settings in the AWS console, return to the command and execute Enter.
![img](https://day-journal.com/memo/images/aws-amplify-015_10.png)

A URL will be issued in the AWS console when the automatic deployment is finished, so access it.
![img](https://day-journal.com/memo/images/aws-amplify-015_11.png)

The deployed WebSite will be displayed.

<br>

## Set Up a Unique Domain with Amplify Console

This is how to set up a unique domain with the Amplify Console. 

Advance Preparation

- Get a unique domain using Amazon Route 53 

[Amazon Route 53 #001 - Purchase and register your domain name](https://day-journal.com/memo/amazon-route53-001)

![img](https://day-journal.com/memo/images/amazon-route53-001_08.png)

Click on "Manage Domains."
![img](https://day-journal.com/memo/images/aws-amplify-013_01.png)

Click on "Add Domain."
![img](https://day-journal.com/memo/images/aws-amplify-013_02.png)

Select the target domain → Click "Configure Domain."
![img](https://day-journal.com/memo/images/aws-amplify-013_03.png)

Confirm the target domain and branch → Click "Save."
![img](https://day-journal.com/memo/images/aws-amplify-013_04.png)

After the settings are complete, access a unique domain.
![img](https://day-journal.com/memo/images/aws-amplify-013_05.png)

Your website will appear on your domain.

<br>

## Custom Hosting Environment for a Unique Domain Built from Amplify CLI

Finally, we will build a unique domain hosting environment using Amazon CloudFront and Amazon S3 directly from the Amplify CLI.

## Custom Publishing (Amplify CLI)

This is a custom publishing method using Amplify CLI.

Advance Preparation

- Build AWS Amplify environment

[AWS Amplify #002 - Building Environment [Vue.js Version]](https://day-journal.com/memo/aws-amplify-002)

Execution environment

- node v16.10.0
- npm v7.24.0

Set up the hosting environment. Select "Amazon CloudFront and S3" at runtime.

```shell
amplify add hosting
```

![img](https://day-journal.com/memo/images/aws-amplify-012_01.png)

![img](https://day-journal.com/memo/images/aws-amplify-012_02.png)

Confirm the configuration.

```shell
amplify status
```

![img](https://day-journal.com/memo/images/aws-amplify-012_03.png)

Automatically build and deploy your application to the cloud.

```shell
amplify publish
```

![img](https://day-journal.com/memo/images/aws-amplify-012_04.png)

Confirm that the application is not deployed in the AWS Amplify Console.
![img](https://day-journal.com/memo/images/aws-amplify-012_05.png)

Make sure it is automatically deployed to Amazon S3.
![img](https://day-journal.com/memo/images/aws-amplify-012_06.png)

Make sure it is automatically deployed to Amazon CloudFront. Access the URL that was created.
![img](https://day-journal.com/memo/images/aws-amplify-012_07.png)

When you access the deployed URL, you may not be able to see it immediately depending on your region. According to "[Amplify Docs - Hosting](https://docs.amplify.aws/cli/hosting/hosting/#amazon-s3-and-amazon-cloudfront)," it should appear in 24 hours. If you want to see it right away, you can use the following settings. 
![img](https://day-journal.com/memo/images/aws-amplify-012_08.png)

Origin → Select the target origin → Click "Edit."
![img](https://day-journal.com/memo/images/aws-amplify-012_09.png)

Select the same origin domain again (a region will be added to the domain), and click "Save Changes."
![img](https://day-journal.com/memo/images/aws-amplify-012_10.png)

The deployed WebSite will be displayed.

If you want to use a unique domain setting or AWS WAF for custom publishing, refer to the following article for additional settings. Alternatively, edit the AWS CloudFormation configuration file in the project.  
[Build a Unique Domain Hosting Environment with Amazon Route 53, AWS WAF, Amazon CloudFront, and Amazon S3](https://dev.to/aws-builders/build-a-unique-domain-hosting-environment-with-amazon-route-53-aws-waf-amazon-cloudfront-and-amazon-s3-5eip)

<br>

Using AWS Amplify, you can build various unique domain hosting environments and automatically build and deploy them in conjunction with GitHub :bulb: 

In the future, I'd like to experiment with AWS CloudFormation, AWS CDK, etc. to see how far each service configuration can be defined.

Related Articles

{% link https://dev.to/aws-builders/automate-building-a-unique-domain-hosting-environment-with-aws-cdk-1dd1 %}
{% link https://dev.to/aws-builders/automate-building-a-unique-domain-hosting-environment-with-aws-cloudformation-4ehl %}
{% link https://dev.to/aws-builders/build-a-unique-domain-hosting-environment-with-amazon-route-53-aws-waf-amazon-cloudfront-and-amazon-s3-5eip %}
{% link https://dev.to/aws-builders/trying-out-various-settings-for-aws-amplify-publishing-39i4 %}
{% link https://dev.to/aws-builders/trying-out-various-settings-for-aws-waf-publishing-5c4n %}
{% link https://dev.to/aws-builders/trying-out-various-settings-for-amazon-cloudfront-publishing-28pp %}
{% link https://dev.to/aws-builders/trying-out-various-settings-for-amazon-s3-publishing-2hd1 %}