Deploy a Compute Instance with a Remote Startup Script – Qwiklab

0 56

Brief Introduction of Challenge Scenario

When you open the page of this lab in Qwiklabs, you can find the task requirements by click the green activity tracker (on the top right of the page) to expand the score box.

The screenshot above shows that there are 4 steps required for completing this lab. Combining with the instruction details, they are translated to the following mission statements.

  1. Create a Google Cloud Storage bucket, and confirm that the bucket contains a file.
  2. Create a Linux virtual machine that runs a remote startup script called install-web.sh from cloud storage.
  3. Confirm that an HTTP access firewall rule exists with tag that applies to that virtual machine.
  4. Confirm the web server can be connected using HTTP and get a non-error response.

Download Sample Startup Script

First of all, find Sample Startup Script below the Start button and the timer of the lab. Then, download the startup script file to your computer. This lab requires a minute for provisioning lab resources. You may make use of this interval to download the file or take a drink.

  1. Upload the Startup Script to a Cloud Storage Bucket
    1. In the web console, navigate to Storage.
    2. Create a bucket with a unique bucket name.
    3. Upload the install-web.sh file to the bucket.
    4. Make the file publicly accessible (This ensures the file can be access by the VM instance deployed soon).
    5. Click the three dots () icon at the right end of the filename. Choose Edit permissions in the dropdown menu.
    6. Click the three dots () icon at the right end of the filename. Choose Edit permissions in the dropdown menu.
    7. Click the filename and copy the URL, i.e. gs://.../install-web.sh for later use.
  2. Configure Metadata in Creating VM instance
    1. Go to Compute Engine, create a new VM instance.
    2. Select Allow HTTP traffic under the Firewall section.
    3. Expand Management, security, disks, networking, sole tenancy.
    4. In the Metadata section, add startup-script-url and paste the URL of the script file as the key
    5. Click Create to create the instance.
  3. Inspect Instance Correctly Running Startup Script
    1. Wait for the new VM instance startup.
    2. Click the instance name to open its Details tab. Then, expand the Logs and click Serial port 1 (console).
    3. The startup script automatically installs the Apache web server software while creating the VM instance. You should able to find the log events about downloading the startup script and installing the apache packages.
    4. Open the external IP in your web browser. You should view the Apache default page, if the startup script has been successfully executed.

Leave A Reply

Your email address will not be published.