lab 4 bootstrapping instance

Report 6 Downloads 61 Views
LAB: Bootstrapping and Network Architectures Overview At this point, you've successfully tested out a CloudFormation template that can build out your network architecture on AWS resources in very little time. Already, Asperatus Tech is seeing the benefits of using AWS— you're able to create your network resources faster, more reliably, and less expensively. As part of the next phase of moving more of your network resources into AWS, you've started to work with your operations team to see how to leverage the bootstrapping and auto configuration capabilities of EC2 instances. Both you and your operations counterpart want to see a few proof-of-concepts of these capabilities before you start building out more robust and complicated systems.

Technical Knowledge Prerequisites To successfully complete this lab, you should be familiar with basic Linux server administration and comfortable using the Linux command-line tools.

Topics Covered Here's what you'll do in this lab: 1. Launch a web application which uses a database (RDS) using the UserData field in the AWS Management Console. 2. Observe and identify where this script accesses AWS resources directly (such as from an S3 bucket). 3. Manipulate the bootstrap script to configure database access for itself.

Accessing the qwikLAB™ Lab Environment To access your lab environment in qwikLAB™: 1. To the right of the lab title, click the Start Lab button to launch your qwikLAB™. If you are prompted for a token, use the one distributed to you (or the token you purchased).

Note: A status bar shows the progress of the lab environment creation process. The AWS Management Console is accessible during lab resource creation, but your AWS resources may not be fully available until the process is complete.

2. On the lab details page, notice the lab properties. a. Duration - The time the lab will run before automatically shutting down. b. Setup Time - The estimated time to set up the lab environment. c. AWS Region - The AWS Region in which the lab resources are created.

Bootstrapping and Network Architectures

Note: The AWS Region for your lab will differ depending on your location and the lab setup. 3. In the AWS Management Console section of the qwikLAB™ page, copy the Password to the clipboard.

4. Click the Open Console button.

5. Log into the AWS Management Console using the following steps. a. In the User Name field type awsstudent. b. In the Password field, paste the password copied from the lab details page. c. Click Sign in using our secure server.

Note: The AWS account is automatically generated by qwikLAB™. Also, the login credentials for the awsstudent account are provisioned by qwikLAB™ using AWS Identity Access Management. 6. In the AWS Management Console, click EC2.

Bootstrapping and Network Architectures

Access the RDS endpoint When you access your lab, you'll find that you have an RDS instance up and running. You'll use this instance as the database backend for a web server hosting phpMyAdmin. Access the RDS instance and make note of its endpoint To access the RDS endpoint: 7. 8. 9. 10.

From the AWS Management Console, access the RDS dashboard. Click Instances. You should see a single instance in the Instances table. Select the RDS instance. Copy the endpoint of the instance—you'll need it later. a. Note: Do not include the port number.

Update the security group assigned to the RDS Instance This lab includes a default security group that is automatically created and attached to the RDS instance. Review the security group and update the rules to allow your application to talk to the database. 11. Locate the Security Groups field. You can find this field under the Security and Network section of your RDS information. This field displays the security group currently assigned to the instance. 12. Click the name of the security group. 13. Select the security group attached to the RDS Instance (if it is not already selected). 14. Click Actions, and then select Edit Inbound Rules. 15. From the Type dropdown, select MYSQL. 16. From the Source field, select Custom IP, and the start typing: sg17. You will be prompted with a few options, select the option beginning with the name: qlstack2labinstance. 18. Make a note of this Security Group ID (example: sg-999999), you will need it later. 19. Click Save. Now, let's launch a bootstrapped EC2 instance that connects to the RDS instance.

Download and configure the bootstrapping script Before you launch the EC2 instance, you need to download and configure the bootstrapping script. You can download this script from qwikLab screen, opening the tab marked: Instruction 2. Save this locally, you can open it in any text editor for review. The script does a couple of things: • •

Installs PHPMyAdmin using MySQL Downloads a PHPMyAdmin configuration file from an S3 bucket

Bootstrapping and Network Architectures

• • •

Donwloads an RDS configuration file for PHPMyAdmin from an S3 bucket Sets three environmental variables: CFGHOST, CFGUSER, and CFGPASS Restarts the Apache server

20. To have the script work properly, you need to edit the CFGHOST parameter to point to your RDS endpoint. Edit the line: CFGHOST="" to use the endpoint of your RDS instance. For example: CFGHOST="qmo56c9y35h3d.ceqwu4jmoyzj.us-east-1.rds.amazonaws.com" Notice that you do not need to include the port number. Don’t forget to save the updated script.

Launch an EC2 instance with the bootstrapping script With the script configured, you can now launch an EC2 instance and configure it with the bootstrapping script. To launch the EC2 instance: 1. 2. 3. 4. 5.

6. 7. 8. 9. 10. 11. 12. 13.

From the AWS Management Console, access the EC2 dashboard. Click Launch Instance. From the AMI Selection screen, select the first Amazon Linux AMI offered in the list, click Select. In the Choose an Instance Type screen, select t2.medium from the Instance Type list and click Next: Configure Instance Details. In the Instance Details screen: • Scroll down and click on Advanced Details • Copy your bootstrapping script and paste into the User Data field i. reminder – download this from qwikLab screen, Instruction 2 tab Click Next: Add Storage In the Storage Device Configuration screen, leave the fields unchanged and click Next: Tag Instance. In the Tags screen, create a Name tag with a Value of PHPMyAdmin and click Continue: Configure Security Group In the Security Group screen, click on Select an existing Security Group. From the list, select the Security Group that you noted earlier • It will begin with the name qlstack2-labinstance Click Review and Launch Click Launch Accept the default lab keypair offered, click the acknowledgement box and then click Launch Instances.

Verify that the instance launched correctly When the EC2 instance is launched (this should only take 3-5 minutes), you can verify that it launched correctly with your bootstrapping script. To verify that the instance launched correctly: 1. 2. 3. 4.

From the AWS Management Console, access the EC2 dashboard. Click Instances. Locate the EC2 instance that you launched (it should have the name, PHPMyAdmin) and select it. In the Details tab, locate the Public IP Address for the instance.

Bootstrapping and Network Architectures

5. Using this URL, access PHPMyAdmin as follows: http:///phpmyadmin 6. When prompted for a username and password, use the following: • Username: root • Password: mysqlpassword 7. Under General Settings, select the RDS instance. It should have the same name as the endpoint you identified earlier.

Conclusion Congratulations! You have now created a bootstrapped EC2 instance that installs PHPMyAdmin and connects to an RDS instance. For feedback, suggestions and corrections to this lab, please email [email protected].

Ending the Lab 1. To log out of the AWS Management Console, from the menu, click awsstudent @ [YourAccountNumber] and choose Sign out (where [YourAccountNumber] is the AWS account generated by qwikLAB™).

2. Close any active SSH client sessions or remote desktop sessions. 3. Click the End Lab button on the qwikLAB™ lab details page.

4. When prompted for confirmation, click OK. 5. For My Rating, rate the lab (using the applicable number of stars), optionally type a Comment, and click Submit.

Bootstrapping and Network Architectures

Note: The number of stars indicates the following: 1 star = very dissatisfied, 2 stars = dissatisfied, 3 stars = neutral, 4 stars = satisfied, and 5 stars = very satisfied. Also, you may close the dialog if you do not wish to provide feedback.