Terraform Basics: Understanding `init`, `plan`, and `apply`

45 minutes
  • 3 Learning Objectives

About this Hands-on Lab

`init`, `plan`, and `apply` are the top three commands you will use when initializing, creating an execution plan, and executing the desired state of your configuration file. In this hands-on lab, we will learn how and when to use these three commands.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create a Service Account

Create a service account named Terraform using the Google Cloud console and make sure to give it the Owner role.

Log in to the Host Instance and Ensure Terraform Is Installed

Using the provided virtual machine in our Google Cloud instance, make sure that we have our service account Terraform installed and that we can call it.

Create a Service Account Key within the Instance

In this objective, we need to:

  1. Use the virtual machine to create and set up the Service Account Key.
  2. Create the main.tf configuration file and then create and apply an execution plan.
  3. Use init, plan, and apply to finish our configuration.

Additional Resources

Your team has installed Terraform on an instance. They have tasked you with setting the keys and configuration to be able to use Terraform properly.

For this project, you must:

  1. Make sure the keys are set up to communicate with Terraform.
  2. Make sure the configuration files are initiated.
  3. Execute the config files to test your Terraform deployment.

Note: To make sure the lab is fully provisioned, please allow a few extra minutes before starting the lab. It is also important that the main.tf file has the correct project name and the service account identifier is set up correctly for authorization.

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?