Hashicorp Terraform
Terraform is an infrastructure as code tool that lets you build, change, and version infrastructure safely and efficiently. This includes low-level components like compute instances, storage, and networking, as well as high-level components like DNS entries and SaaS features.
jamlab-terraform: Terraform configurations for provisioning homelab VMs.
Usageඞ
With existing VM template(s) built with Proxmox Builder (ISO) it is possible to provision VMs with Terraform extra fast using Terraform Proxmox provider.
Initializing and verifying configurationඞ
Initialize the configuration directory to download and install the providers defined in the configuration:
Bash | |
---|---|
Format your configurations. Terraform will print out the names of the files it modified, if any:
Bash | |
---|---|
Make sure your configuration is syntactically valid and internally consistent
Bash | |
---|---|
Provisioningඞ
Execute a dry run to verify configuration and see what would be done before executing apply:
Bash | |
---|---|
Apply the plan and provision infrastructure as declared in configurations:
Bash | |
---|---|
Note: use the -auto-approve
flag to skip interactive approval of plan before applying.
Unprovision infrastructure as declared in configurations:
Bash | |
---|---|
Using -compact-warnings
flag will compact output, but still outputs errors in full.
Targeting specific resourcesඞ
Any resources defined in main.tf
can be targeted by using -target="<RESOURCE>.<RESOURCE NAME>"
.
For example, target base-infra
module:
Bash | |
---|---|
Structureඞ
Creating multiple of similar resourceඞ
Create variable to be looped over with the values that will be used for each loop:
Text Only | |
---|---|
And then use for_each
to use the variable to be looped over using the values with keyword each.value.<VALUE INSIDE LOOPED VARIABLE>
:
Text Only | |
---|---|