官术网_书友最值得收藏!

Deploying a static website via AWS S3

Next, let's deploy the frontend web user interface to AWS S3.

One of the buckets we created in the previous chapter was for the purpose of website hosting. Let's configure it via the AWS Management Console for static website hosting:

  1. Navigate to the Amazon S3 service in the management console and click on your bucket.
  2. In the Properties tab, as shown in the following screenshot, click on the Static website hosting card:
  1. When you click on the Static website hosting card, a configuration card will pop up.
  2. Select Use this bucket to host a website and enter index.html and error.html for the Index document and Error document fields, respectively.
  1. Copy the Endpoint URL on your configuration page and then click Save. This endpoint URL will be the public address of your static website:
  1. Next, we can upload the index.html and scripts.js files to this S3 bucket. Before we do that, we need to make a change in scripts.js. Remember, the website will be running in the cloud now, and won't have access to our local HTTP server.
  1. Replace the local server URL in the scripts.js file with the one from our backend deployment, as follows:
"use strict";

const serverUrl = "https://<UID>.execute-api.us-east-1.amazonaws.com/api";
...
  1. Finally, set the permissions of the index.html and scripts.js files to publicly readable. To do that, we need to modify the S3 bucket permissions under the Permissions tab.
  2. Click on the Public access settings button, uncheck all four checkboxes, and then type confirm to confirm these changes. This will allow the contents of this S3 bucket to be made publicly accessible, as follows:

  1. Now, we are able to make the files public by selecting both files, clicking on Actions, and clicking on Make public, as shown in the following screenshot:

Open the S3 endpoint URL in your browser. The URL should look something like http://<BUCKET>.s3-website-us-east-1.amazonaws.com/.

Your ObjectDetector website is now running in your browser and it's communicating with the backend running on AWS to demo your intelligent-enabled application's capability. Both the frontend and the backend are serverless and both are running on the AWS cloud infrastructure, which scales automatically with demand.

Congratulations! You've just developed an end-to-end AI application to AWS! You can now share this AI application with anyone in the world with a browser.

Even though your new AWS account might have free-tier services, you should still limit the number of people you share the website URL and API endpoints with. You will be charged if the AWS resources that are consumed exceed the amount that's covered under the free-tier plan.
主站蜘蛛池模板: 中卫市| 慈溪市| 湖州市| 东乌| 霍城县| 哈密市| 玛沁县| 潼关县| 唐海县| 南开区| 巴中市| 莱西市| 彰武县| 玛纳斯县| 图木舒克市| 辽宁省| 新河县| 毕节市| 岳池县| 江西省| 磐石市| 延长县| 宝清县| 淳化县| 南汇区| 南部县| 花莲县| 大新县| 密云县| 南宁市| 开鲁县| 汤阴县| 泽库县| 额济纳旗| 加查县| 天津市| 海安县| 沅陵县| 皮山县| 兴义市| 韶关市|