<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 眼鏡蛇 閱讀(148) 評論(0)  編輯  收藏 所屬分類: AWS

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

    導(dǎo)航

    統(tǒng)計(jì)

    常用鏈接

    留言簿(6)

    隨筆分類

    隨筆檔案

    文章分類

    文章檔案

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 亚洲中文字幕第一页在线| 国产妇乱子伦视频免费| 免费v片视频在线观看视频| 亚洲香蕉久久一区二区三区四区| 十九岁在线观看免费完整版电影| 亚洲最大激情中文字幕| 中文字幕免费在线播放| 亚洲AV无码欧洲AV无码网站| 花蝴蝶免费视频在线观看高清版 | 国产精品无码一二区免费| 亚洲综合中文字幕无线码| 野花高清在线观看免费3中文| 亚洲人成片在线观看| 免费A级毛片无码免费视| 亚洲日韩一中文字暮| 青青青青青青久久久免费观看| 亚洲AV性色在线观看| 亚洲国产成人久久综合区| GOGOGO高清免费看韩国| 亚洲无删减国产精品一区| 思思re热免费精品视频66| 亚洲人成电影网站色www| 亚洲精品国产自在久久| 9久热精品免费观看视频| 亚洲AV日韩精品久久久久| 18国产精品白浆在线观看免费| 亚洲免费综合色在线视频| 亚洲午夜激情视频| 国产麻豆一精品一AV一免费| 亚洲男人的天堂久久精品| 四虎亚洲国产成人久久精品| 十八禁视频在线观看免费无码无遮挡骂过 | 亚洲看片无码在线视频| www亚洲精品少妇裸乳一区二区| 九九全国免费视频| 亚洲欧洲国产精品你懂的| 免费黄色大片网站| 91视频免费观看高清观看完整| 亚洲乱码卡三乱码新区| 亚洲国产天堂久久久久久| 久久精品无码专区免费东京热|