The Null Resource, Provisioners, and Triggers

Study the null resources, provisioners, and triggers in Terraform.

Overview

This lesson introduces three useful techniques used in Terraform:

  • The null resource is a resource that explicitly does not create anything.
  • The provisioners set up resources upon creation or change.
  • The triggers allow the user to exercise some control over when provisioners are run.

Importance

This lesson is important as it covers tools (listed above) that are widely used in the Terraform code.

Learning about null resources is useful for debugging, and it’s widely used in various contexts when we’re reading others’ code. Provisioners is a central concept in Terraform, and triggers are a useful mechanism to know about in Terraform provisioners.

Null resources

Sometimes it’s useful to have a resource that effectively creates nothing. Terraform provides such a resource called a null_resource.

Within this resource, we can perform other actions that may be useful for our provisioning workflow.

Let’s start with a simple but useful example. We’ve created a directory, ltthw_null_resource, with a main.tf resource in it. The terraform init command is already executed. Run terraform plan and observe what happens.

Get hands-on with 1200+ tech skills courses.