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

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.
主站蜘蛛池模板: 阿尔山市| 周口市| 宕昌县| 江门市| 英德市| 苍溪县| 兴海县| 德昌县| 文山县| 临武县| 哈尔滨市| 宿松县| 会东县| 类乌齐县| 仙居县| 锡林郭勒盟| 郓城县| 长泰县| 彭山县| 雷山县| 阆中市| 光山县| 瓮安县| 夏津县| 三门县| 阿合奇县| 尉犁县| 沐川县| 松江区| 黄平县| 大洼县| 麻江县| 宿州市| 酒泉市| 成安县| 汝城县| 延边| 新干县| 虹口区| 阆中市| 塘沽区|