0PricingLogin
Terraform Infrastructure as Code · Lesson

Null Resources and Triggers

Discover `null_resource` for executing arbitrary commands that don't map to a real cloud resource, and use triggers to control when provisioners run.

What is null_resource?

Terraform's null_resource is a special type of resource that doesn't directly create or manage any infrastructure object in your cloud provider.

Instead, it acts as a placeholder for running arbitrary commands or scripts, often used for tasks that fall outside the scope of typical resource provisioning.

Why Use null_resource?

You might wonder why you'd need a 'null' resource. It's incredibly useful for:

  • Running Local Scripts: Executing commands on the machine where Terraform is run (e.g., preparing configuration files).
  • Post-Deployment Actions: Performing setup or cleanup tasks after real resources are provisioned.
  • Interacting with External APIs: When a dedicated Terraform provider doesn't exist for a specific service.
  • Custom Logic: Orchestrating custom steps that aren't tied to a specific cloud resource.

All lessons in this course

  1. Querying Data with Data Sources
  2. Local and Remote Exec Provisioners
  3. Null Resources and Triggers
  4. Using External Data and Templates
← Back to Terraform Infrastructure as Code