<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    create an Amazon RDS database instance

    In this exercise, you will create an Amazon RDS database instance and store the Amazon S3 object key for the photo and photo labels in the database. This way, you are storing your data in a more structured format and making the application scalable. 
    Note: Make sure to sign in to your AWS account with the AWS IAM user edXProjectUser credentials.

    To get started, follow the instructions below.

    1. Create an Amazon RDS database instance.

    In this section, you will create an Amazon RDS instance with the properties shown below to store photos and labels. If you are familiar with Amazon RDS, you may want to attempt to complete this section before reading the step-by-step instructions.

    Region: Oregon (us-west-2)
    Amazon RDS Instance type: MySQL (free tier eligible)
    Name of DB instance: edx-photos-db 
    Master username: master 
    Master user password: Type a master user password and write it down for later use.
    VPC: edx-build-aws-vpc 
    Database name: Photos
    Important: Make a note of the database endpoint.


    • In the AWS Console, click Services, then click Relational Database Service to open the Amazon RDS dashboard.
    • Make sure you are still in the Oregon AWS Region.
    • On the left navigation menu, click Instances.
    • Click Launch DB instance.
    • Scroll down to the bottom and select the Only enable options eligible for RDS free usage tier option.
    • Scroll back to the top and select MySQL.
    • Click Next.
    • Leave the default selections and scroll down to Settings.
    • For DB instance identifier, type edx-photos-db
    • For Master username, type master
    • Type a password for the master user and confirm the password. Make a note of the password for later use.
    • Click Next.
    • In the Network & Security section, select edx-build-aws-vpc.
    • Scroll down to Database options.
    • For Database name, type Photos. Make a note of the database name for later use.
    • Leave the rest of the default settings, scroll down to the bottom and click Launch DB instance.
    • Note: It should take about five minutes for the instance to launch.

    • Click View DB instance details to go to the DB instance details page.
    • After the instance launches, scroll down to the Connect section and make a note of the Endpoint for later use. 
      The endpoint will look like this: sample.cppyk3cpwnox.us-west-2.rds.amazonaws.com.

    2. Modify the security group of the Amazon RDS database.

    In this section, you will modify the security group of the Amazon RDS instance to the security group of the AWS Cloud9 instance.

    • On the Amazon RDS database instance page, scroll down to the Details section.
    • Under Security and network, click the security group. The security group should have a name like rds-launch-wizard-xxx. A new page displaying the security group you just clicked should open.
    • Make a note of the security group ID. You will need it in subsequent exercises.
    • On the bottom pane, click Inbound.
    • Click Edit.
    • In the Source textbox, delete the existing text and type sg. A list of security groups will appear. Select the security group that contains your AWS Cloud9 environment name.
    • Click Save.

    3. Download the exercise code .zip file and unzip it to your AWS Cloud9 environment.

    In this section, you will download the exercise code .zip file and unzip it to your AWS Cloud9 environment. If you feel familiar with the AWS Cloud9 environment from the previous few exercises, you may want to attempt to complete this section before reading the step-by-step instructions.

    Exercise code: wget https://s3-us-west-2.amazonaws.com/us-west-2-tcdev/courses/AWS-100-ADG/v1.0.0/exercises/ex-rds.zip 
    Unzip command: unzip ex-rds.zip


    • Type the command below in your AWS Cloud9 terminal to make sure you are in the ~/environment directory of your AWS Cloud9 instance.

      cd ~/environment
    • Type the command below in your AWS Cloud9 terminal to download the Python code for the Amazon RDS database component.
    • wget https://s3-us-west-2.amazonaws.com/us-west-2-tcdev/courses/AWS-100-ADG/v1.0.0/exercises/ex-rds.zip

      On the left tree view, you should see the exercise code .zip file named ex-rds.zip.

    • Unzip the exercise code zip file by typing the command below on your Cloud9 terminal.
    • unzip ex-rds.zip

      The contents of the .zip file should be extracted to a folder with a similar name. You can view the folder on the left tree view.

    4. Explore the exercise code.

    • In your AWS Cloud9 environment, on the left tree view, notice the exercise-rds/SetupScripts/database_create_tables.py file. This script creates the database tables needed for the application. The photo table stores the photos and labels information. The web_user is a restricted privilege user who has access solely to the photos table. The web application is configured to use the web_user and not the master user.
    • Open the exercise-rds/FlaskApp/database.py file and explore the code for adding a photo to the database and fetching it back from the database.

    5. Run the database script.

    • To run the database_create_tables.py script, type the command below in your AWS Cloud9 terminal window.
    • python3 exercise-rds/SetupScripts/database_create_tables.py

    • You should see a prompt on the screen to configure the database information. Follow the prompts and enter the information as shown below. 
      Database host: Paste the database endpoint you noted earlier.
      Database user: master
      Database password: Type the password for the master user.
      Database name: Photos
      web_user password: Type a password for the web_user. Make a note of the web_user password for later use.

      You should see a message that a web_user is created with the required access granted to it.

    6. Configure environment variables and run and test the code.

    • For the code to run successfully, you will need to configure the environment variables with the database details. Under the FlaskApp folder, open the config.py file. Notice that the config.py file is now updated with the database-related environment variables.
    • In your AWS Cloud9 environment, on the Run Configuration pane at the bottom, click ENV on the right side. You should see a small list showing the previously configured environment variables.
    • To configure the database environment variables, type the environment variable Name and Value as shown in the table below:
      Name Value
      DATABASE_HOST Database endpoint you noted earlier
      DATABASE_USER web_user
      DATABASE_PASSWORD Password for the web_user you noted earlier
      DATABASE_DB_NAME Photos

      Note: Make sure to delete any white space inserted while copy/pasting.

    • To run the code, you will need to point the Run Configuration to the correct exercise folder. On Python3RunConfiguration pane at the bottom, in the Command textbox, type the text shown below and click Run on the left side.
    • exercise-rds/FlaskApp/application.py

      You should see a message like this one:

      Running on http://0.0.0.0:5000

    • To test the code, go to your browser and type the IP address of the AWS Cloud9 environment. At the end of the IP address, type :5000 
      You should see the application running on port 5000.
    • Click Home and upload a photo. You should see the photo and the Amazon Rekognition labels generated for the photo.
    • Click Home. You should see a table with the thumbnail for the photo and the label information. This information is being fetched from the database.
    • Try uploading a few more photos and watch as the table on the Home page is populated with the information saved in the database.

    Optional Challenge

    There is a command line mysql client on your Cloud9 instance.

    The mysql client takes parameters for the database host and user. A "-p" switch tells the client to prompt you for a password. To connect to your RDS database, run the command below (replace DATABASE_HOST with your RDS database endpoint).

    mysql -h DATABASE_HOST -u web_user -p

    Can you SELECT the contents of the photo table?

    7. Stop the Amazon RDS database instance.

    To keep your AWS account bill to a minimum, consider stopping the Amazon RDS instance and then starting it again when needed. Follow the steps below to stop the Amazon RDS database instance.

    • In the AWS Console, click Services, then click Relational Database Service to open the Amazon RDS dashboard.
    • In the left navigation pane, click Instances. From the list of instances, select edx-photos-db.
    • At the top, click Instance actions -> Stop. You will get a prompt. Click Yes, stop now.


    眼鏡蛇

    posted on 2018-04-19 11:18 眼鏡蛇 閱讀(149) 評論(0)  編輯  收藏 所屬分類: AWS

    <2025年5月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    導航

    統計

    常用鏈接

    留言簿(6)

    隨筆分類

    隨筆檔案

    文章分類

    文章檔案

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 久久精品国产亚洲夜色AV网站| 免费在线不卡视频| 亚洲精品美女久久久久| 国产免费无码一区二区| 亚洲AV无码成人精品区蜜桃 | 色欲aⅴ亚洲情无码AV蜜桃| 成人免费无码大片A毛片抽搐| 亚洲人成人网毛片在线播放| 在线观看免费人成视频| 久久精品国产亚洲αv忘忧草| 91在线视频免费看| 亚洲.国产.欧美一区二区三区| www.亚洲色图| a级片在线免费看| 亚洲欧洲春色校园另类小说| 国色精品卡一卡2卡3卡4卡免费| 2020亚洲男人天堂精品| 国产又大又粗又硬又长免费| 思思久久99热免费精品6| 国产亚洲av片在线观看播放| 中文字幕在线免费观看| 亚洲国产日韩精品| 亚洲毛片不卡av在线播放一区| 全黄大全大色全免费大片| 亚洲视频在线一区二区三区| 午夜视频在线在免费| 男人扒开添女人下部免费视频| 亚洲国产精品嫩草影院在线观看 | 全免费a级毛片免费**视频| 免费国产va视频永久在线观看| 亚洲中文字幕无码中文字在线| 2021在线永久免费视频| 老司机亚洲精品影院在线观看| 亚洲精品午夜无码电影网| 无码精品A∨在线观看免费| 免费精品国自产拍在线播放| 久久亚洲AV无码精品色午夜 | 亚洲美女免费视频| 免费一级做a爰片性色毛片| 国产一区二区免费| 亚洲av色香蕉一区二区三区蜜桃|