Using Terraform Provisioners to Set Up an Apache Web Server on AWS

45 minutes
  • 3 Learning Objectives

About this Hands-on Lab

In this hands-on lab, we’ll be using a Terraform provisioner to custom bootstrap a VM in AWS and install a webserver on it, and then test that the webserver is working as expected.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Clone Terraform Code and Switch to the Proper Directory
  1. Clone the code required for the lab from the provided GitHub repository.
  2. Switch to the directory where the code required for this lab resides (content-hashicorp-certified-terraform-associate-foundations/section3-hol2/).
Examine the Code in the File
  1. View the contents of the file.
  2. Examine the code in the resource block that is creating the EC2 instance (your virtual machine).
  3. Examine the code in the provisioner block that is issuing commands to be carried out on that resource once it is created.
Deploy the Code and Access the Bootstrapped Webserver
  1. Initialize the working directory and download the required providers with the terraform init command.
  2. Validate the code using the terraform validate command.
  3. Review the actions that will be performed when you deploy the code using the terraform plan command.
  4. Deploy the code with the terraform apply command.
  5. Navigate to the bootstrapped webserver’s IP address, and validate that the provisioner worked as intended.

Additional Resources

Link to the GitHub repository for this lab:

To get started, log in to the lab server using the credentials provided:

ssh cloud_user@<PublicIP>

Note: The lab server already has the permissions required to deploy infrastructure within AWS using the provided code that includes Terraform provisioners.

And, in a web browser, log in to the AWS Management Console using the credentials provided.

What are Hands-on Labs

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.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?