Terraform cont
Installing in virtual machines/ec2 instances
- All the clouds have cloud-init enabled and this is recommended. Cloud-init is executed only once during machine creation. Refer Here for the changes done.
- Other option is use provisioning which is not recommened
- Terraform has provisioners of three types
- file: This is used to copy files or folders from the machine where terraform is runnning into machine created by terraform
- local-exec: This will execute a command/script locally on the machine where terraform is running
- remote-exec: This will execute a command/script remotely on the machine create by terraform
- Whenever the provisioner needs to connect to a remote machine it requires a connection
- Connection arguments
- Refer Here for the changes
- Provisioners will be executed only when the resource is created. If you want to trigger provisioners, we have to re create resources, in terrform there is null_resource
- Refer Here for the changes done to handle script execution
