Trying Out Various Settings for AWS Amplify Publishing
Tags: amplify, amplifyconsole, aws
Published: 2022-02-14 11:23:02

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

### I've been experimenting with various settings for AWS Amplify publishing :tada:  

<br>

There are three main ways to publish to AWS Amplify.

1. Publish via the Amplify Console using the AWS console
2. Publish via the Amplify Console using the Amplify CLI
3. Custom publishing using the Amplify CLI

<br>

The following is a detailed explanation.

- Publish with Amplify Console
- Publish Basic Authentication in Amplify Console
- How to support routing in Amplify Console
- Publish with Amplify Console (Amplify CLI)
- Custom Publishing (Amplify CLI)
- Deleting Public Settings (Amplify CLI)

<br>

## Publish with Amplify Console

This is how to publish in the Amplify Console.

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

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

Click on "Deploy without a Git provider" to keep it simple this time.
![img](https://day-journal.com/memo/images/aws-amplify-007_03.png)

Set the application name and environment name as desired. Drag and drop the set of files you want to publish, and click "Save and Deploy." As a sample, we will use a manually built application built with Vue.js.
![img](https://day-journal.com/memo/images/aws-amplify-007_05.png)

The files to be uploaded are zipped using the following command; if they are compressed using the standard Mac GUI, they cannot be displayed even after deployment.

```shell
zip -r xxxxx.zip *
```

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

When the upload is finished, the URL will be issued.
![img](https://day-journal.com/memo/images/aws-amplify-007_06.png)

The uploaded WebSite will be displayed.
![img](https://day-journal.com/memo/images/aws-amplify-007_07.png)

Although it does not appear on the console, it seems that the deployment is being done internally using Amazon S3 and Amazon CloudFront.

<br>

## Publish Basic Authentication in Amplify Console

This is how to publish Basic Authentication in Amplify Console. 

As a preliminary preparation, display your WebSite in Amplify Console.

Click Access Control → Click "Manage Access."
![img](https://day-journal.com/memo/images/aws-amplify-008_01.png)

Set Access Settings to Restricted. Set the user and password → Click "Save."
![img](https://day-journal.com/memo/images/aws-amplify-008_02.png)

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

When you access the URL, you will be prompted to enter the user and password.
![img](https://day-journal.com/memo/images/aws-amplify-008_04.png)

Enter the user and password you set, and then the WebSite will appear.

<br>

## How to support routing in Amplify Console

This is how to handle routing in the Amplify Console.

In advance, display your WebSite in the Amplify Console.

Rewrite the redirect → Click "Edit."
![img](https://day-journal.com/memo/images//aws-amplify-009_01.png)

Set the source address, target address, and input → Click "Edit." Enter the setting values referring to the [AWS Amplify User Guide](https://docs.aws.amazon.com/amplify/latest/userguide/redirects.html).

Original address

```text
</^[^.]+$|\.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|woff2|ttf|map|json)$)([^.]+$)/>
```

Destination Address

```text
/index.html
```

Redirect Type

```text
200
```

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

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

You should now see the routing page.
![img](https://day-journal.com/memo/images/aws-amplify-009_04.png)

<br>

## Publish with Amplify Console (Amplify CLI)

This is how to publish with Amplify Console using Amplify CLI. This hosting environment will be the same as "Publish with Amplify Console."

As a preliminary preparation, build the AWS Amplify environment.
[AWS Amplify #002 - Build 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" at runtime.

```shell
amplify add hosting
```

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

Confirm the configuration.

```shell
amplify status
```

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


Automatically build and deploy your application to the cloud.

```shell
amplify publish
```

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


When the deployment is complete, a URL will be issued in the AWS console, which you can access.
![img](https://day-journal.com/memo/images/aws-amplify-010_04.png)

The deployed WebSite will be displayed.

<br>

## Custom Publishing (Amplify CLI)

This is a custom publishing method using Amplify CLI.

As a preliminary preparation, build the AWS Amplify environment.
[AWS Amplify #002 - Build 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 set IP restrictions and Basic authentication for custom publishing, refer to the following article for additional settings. Alternatively, edit the AWS CloudFormation configuration file in the project.

{% 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-aws-waf-publishing-5c4n %}

<br>

## Deleting public settings (Amplify CLI)

This is how to delete the publish settings using Amplify CLI. In the case of custom publishing, Amazon CloudFront will be deleted automatically, but Amazon S3 buckets will not be deleted, so you will need to delete them separately.

Configure the removal of the hosting environment.

```shell
amplify remove hosting
```

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

Check the configuration.

```shell
amplify status
```

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

Remove the hosting environment.

```shell
amplify push
```

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

Confirm that the hosting environment has been automatically removed from the AWS console.
![img](https://day-journal.com/memo/images/aws-amplify-011_04.png)

<br>

AWS Amplify allows you to publish in the Amplify Console, custom publishing, and Basic authentication :bulb: 

In the next article, I hope to show you how to build your unique domain hosting environment for AWS Amplify.

Related Articles

{% 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 %}