https://github.com/devenes/provisioner
https://github.com/devenes/provisioner
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/devenes/provisioner
- Owner: devenes
- Created: 2022-04-09T13:23:42.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-04-09T13:40:10.000Z (almost 4 years ago)
- Last Synced: 2025-01-03T15:44:05.226Z (about 1 year ago)
- Language: HCL
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Terraform Provisioners
- Provisioners can be used to model specific actions on the local machine or on a remote machine in order to prepare servers or other infrastructure objects for service.
- 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.
- 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. To invoke a local process, see the local-exec provisioner instead. The remote-exec provisioner supports both ssh and winrm type connections.
- 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.
- Most provisioners require access to the remote resource via SSH or WinRM, and expect a nested connection block with details about how to connect. Connection blocks don't take a block label, and can be nested within either a resource or a provisioner.
- The `self` object represents the provisioner's parent resource, and has all of that resource's attributes. For example, use `self.public_ip` to reference an aws_instance's public_ip attribute.
- Take your `pem file` to your local instance's home folder for using `remote-exec` provisioner.
- Go to your local machine and run the following command.
```bash
scp -i ~/.ssh/ ec2-user@:/home/ec2-user
```
- Or you can drag and drop your pem file to VS Code. Then change permissions of the pem file.
```bash
chmod 400
```
- Create a folder name `Provisioners` and create a file name `main.tf`. Add the followings.
```bash
mkdir Provisioners && cd Provisioners && touch main.tf
```