You are currently viewing Terraform Provisioner

Terraform Provisioner

Terraform Provisioner

Hello Everyone

Welcome to CloudAffaire and this is Debjeet.

In the last blog post, we have discussed terraform output.

https://cloudaffaire.com/terraform-output/

In this blog post, we will discuss terraform provisioner.

What is Terraform Provisioner?

Provisioners are used to execute scripts on a local or remote machine as part of resource creation or destruction. Provisioners can be used to bootstrap a resource, cleanup before destroy, run configuration management, etc.

Provisioners types:

  • Provisioner Connections: Many provisioners require access to the remote resource. For example, a provisioner may need to use SSH or WinRM to connect to the resource. Any connection information provided in a resource will apply to all the provisioners, but it can be scoped to a single provisioner as well.
  • Provisioners Without a Resource: If you need to run provisioners that aren’t directly associated with a specific resource, you can associate them with a null_resource.
  • Chef Provisioner: The chef provisioner installs, configures and runs the Chef Client on a remote resource. The chef provisioner supports both ssh and winrm type connections.
  • File Provisioner: The file provisioner is used to copy files or directories from the machine executing Terraform to the newly created resource. The file provisioner supports both ssh and winrm type connections.
  • Habitat Provisioner: The habitat provisioner installs the Habitat supervisor and loads configured services. This provisioner only supports Linux targets using the ssh connection type at this time.
  • local-exec Provisioner: The local-exec provisioner invokes a local executable after a resource is created. This invokes a process on the machine running Terraform, not on the resource.
  • remote-exec Provisioner: The remote-exec provisioner invokes a script on a remote resource after it is created. This can be used to run a configuration management tool, bootstrap into a cluster, etc.
  • Salt Masterless Provisioner: The salt-masterless Terraform provisioner provisions machines built by Terraform using Salt states, without connecting to a Salt master. The salt-masterless provisioner supports ssh connections.

Provisioner Syntax:

Provisioner demo:

Hope you have enjoyed this article. In the next blog post, we will discuss terraform override.

To get more details on terraform, please refer below terraform documentation

https://www.terraform.io/docs/index.html