Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Google Cloud Platform icon
Labs

EC2 Instance Bootstrapping

Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides secure, resizable compute capacity in the cloud. In this lab, we configure a web server to corporate standards, noting how much effort it can take to walk through these steps manually each time. We then learn how to bootstrap an instance using a user data script, allowing us to automatically build servers. By the end of this lab, the user will understand what an EC2 bootstrap script is and how to use one to automate one of the most tedious parts of server building.

Google Cloud Platform icon
Labs

Path Info

Level
Clock icon Beginner
Duration
Clock icon 1h 0m
Published
Clock icon Jun 30, 2021

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Manually Install Software on webserver-01

    On the instance webserver-01, which is already setup in the AWS Account, complete the following tasks:

    • Update the cache of available packages using the Aptitude Package Manager
    • Install the Apache2 Web Server, and ensure you can connect to it using your browser
    • Install the unzip utility, and use it to download and install the AWS CLI v2
    • Build a new index.html file for Apache to include the following details, gathered from the instance metadata service
      • Availability Zone
      • Instance ID
      • Public IP
      • Private IP Address
    • Install mysql-server.
    • Confirm that the new page loads in your browser
  2. Challenge

    Use a Bootstrap Script to Build webserver-02 and Debug Issues

    We will now create an instance to be configured the same as above, but accomplished using bootstrapping instead of manual configuration.

    Create a new EC2 instance running Ubuntu Server 20.04. Ensure it is created with a Public IP, using the EC2SecurityGroup, and with the name webserver-02. In the Advanced section, make sure to enable the use of both V1 and V2 for the Metadata. When creating the instance, use the bootstrap script provided on the A Cloud Guru GitHub:

    https://github.com/ACloudGuru-Resources/course-aws-certified-solutions-architect-associate/blob/main/lab/ec2-instance-bootstrapping/webserver-02.sh

    After launching the instance:

    • Use aws --version to confirm that the correct version of the CLI is installed
    • Use systemctl and ps commands to verify that Apache is running.
    • Investigate why MySQL was not installed and resolve the issue manually.

    Note that we will resolve the issue with the bootstrap in the next objective.

  3. Challenge

    Use a Fixed Bootstrap Script to Build webserver-03

    When configuring webserver-02, our script attempted to install mysqld, but it failed to complete. Before setting up webserver-03, we will need to fix the bootstrap script which we used on webserver-02.

    Analyze the bootstrap script for webserver-02, and resolve the issue that would have prevented mysqld from installing, then run the lab. The fully repaired bootstrap script is also available in the Lab Guide when running this lab in Guided mode (not available in Challenge mode).

    Tip! Remember that bootstrap scripts can't require user interaction. Check the commands used to install other packages to identify the difference. In the Advanced section, make sure to enable the use of both V1 and V2 for the Metadata.

    Build the instance using the same specifications as previously, but with the name webserver-03, and the repaired bootstrap script. Login to the instance, and use systemctl and ps commands to confirm that mysql is running as expected.

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans