Terraform provisioner:
provisioner are used to execute scripts on a local or remote machine as part of resource creation or destruction.
provisioners are inside resource block
- local-exec: this invokes a local executable after a resource created. where your terraform is running.
ex: you have to created a ec2 machine, you want to fetch an IP address of your vm and it has to store in ip address of your file called server-ip.txt here the ip address get saved locally.
- remote exec: this invokes a remote executable after a resouce created.
ex: if you want to install nginx /any software , if we can provide the pem file using remote exec, it will connect using ssh and it will install the software on remote machine
we need connection block for remote exec.