Provision Proxmox VMs quickly and easily with Terraform (2023)

Update: We have uploaded an update to this article with Terraform 1.0. You can find it here:Terraform 1 and Proxmox; works as it should

Previously I wrote an article about deploying Proxmox VMs with Ansible, you can find itHere.

This article looked at how a functional Ansible script works, which provisions Proxmox virtual machines in a simple and streamlined way and can be integrated into many other implementations.

This time we're going to look at Terraform with a different possibility.

Terraform allows us to streamline the process even further by using plugins, much like Ansible would do.

Both methods depend on a template to be created beforehand. You could of course just create an empty virtual machine and it would work, but that means you have to do the OS installation manually, where's the fun in that?

Inside Proxmox, the VM creation method is (using the GUI):

Create VM -> Present OS ISO on VM -> Perform installation -> Enjoy

This process takes too long, is manual (eww) and frankly it's just plain boring. Especially if you need to create multiple VMs.

Let's create a template for Terraform to use.

Creating a template

Within Proxmox you can (usually) choose two ways to create a VM, via the GUI or via the terminal console. For this example, you should use a machine with the bare minimum and the minimum resources allocated to it. This way it can be easily scaled in the future.

You need a VM with the following resources:

1 Kern
1 GB of memory
10GB hard drive
1 network interface
1 cloud init drive
1 EFI hard drive

(Video) Tutorial: How to deploy VMs in Proxmox using Terraform

Some of the above properties need to be added after the VM creation process.

Creating the template manually

The process of creating a VM within the Proxmox GUI has been explained countless times on the internet. For the sake of completeness, we mention the basic process:

1) Click Create VM
2) Enter a name for the VM, you can check if it starts on boot, your call. Click next
3) Choose an ISO to install and select the type and version of the operating system to install. Click next
4) Enable the "Qemu Agent" option, you will use this later. Click next
5) Select the disk size, in this case 10GB. You can also change some of the storage emulation options for that drive, we won't go into that in this example. Click next
6) Select how many cores you want to use for the VM, in this case 1 core. Click next
7) Enter the amount of memory for the VM, in this case 1024 MB. I recommend using the ballooning device so you can save memory resources on the node and oversell the resources just like you would with a CPU. Note that if the memory is actually used by the VM, it cannot be used by other VMs unless they are in the exact same block of memory. Enter KSM (Kernel Shared Memory) Impressive. Select the minimum memory for the ballooning device, in this case 256MB. Click next
8) If you don't have any custom network configurations on the node, you can just click Next here. In this case, make sure that the configuration meets your requirements.
9) Confirm VM setup and click FinishDo not start the VM yet

After the VM is created, you need to change a few things on the VM. As you can see from the steps above, the cloud-init drive has not been added. Select the VM on the left and click Hardware, then Add, and finally Cloud-Init Drive and select the storage where you want it to reside.

Then edit the BIOS (double click on the BIOS entry under the Hardware tab) and select OVMF (UEFI)

Finally the EFI disk, it's the same process as the cloudinit drive, but now select EFI disk and the storage where it will reside. You cannot create the drive before setting up the BIOS in the second step.

In the VM's terminal, you can go ahead and install the packages from cloud-init so the VM is ready to use with:

apt-get install cloud-init -y

Using Debian's official image for cloud-init.

If the manual process above is taking too long and you don't want to spend so much time installing the operating system, you can simply download a preconfigured image from the official Debian repositories.

In the terminal of the proxmox node, run:


Since we have described the process through GUI in manual installation, let's go to CLI method, the commands are as follows:

qm create 9000 -name debian-10-template -memory 1024 -net0 virtio,bridge=vmbr0 -cores 1 -sockets 1 -cpu cputype=kvm64 -description "Debian 10 cloud image" -kvm 1 -numa 1qm importdisk 9000 debian-10 -openstack-amd64.qcow2 lvm-thinqm set 9000 -scsihw virtio-scsi-pci -virtio0 lvm-thin:vm-9000-disk-1qm set 9000 -serial0 socketqm set 9000 -boot c -bootdisk virtio0qm set 9000 -agent 1qm set 9000 -hotplug disk,network,usb,memory,cpuqm set 9000 -vcpus 1qm set 9000 -vga qxlqm set 9000 -name debian-10-templateqm set 9000 -ide2 lvm-thin:cloudinitqm set 9000 -sshkey /etc/pve/pub_keys /

Please, please, please consider that the disk needs to be resized to 10GB in order for the VM to have space to grow while running. You can do this from the "Hardware" tab in the GUI.

template setup

Ok, you've created the template, now what?

(Video) Proxmox virtual machine *automation* in Terraform

The template must contain some packages to work smoothly. Not all of these packages are essential, but I usually opt for:

sudo apt install bmon screen ntpdate vim locales-all iotop auf curl libpam-systemd python-pip python-dev ifenslave vlan mysql-client sysstat snmpd sudo lynx rsync nfs-common tcpdump strace darkstat qemu-guest-agent

Define template

When the VM has been shut down cleanly you can go ahead and convert it to a template, this can be done on the Proxmox GUI by right clicking on the VM and clicking "Convert to Template".

In this case we rename the VM template to:debian-cloudinit

Success, the template has been created.

Enter Terraform

Terraform works pretty simply.

It uses an HCL format file (similar to JSON) which is JSON compatible.

Within this file (or files) you can define a complete infrastructure. How simple or complex it can be is up to you. For this example it's going to be a fairly simple infrastructure definition, after all we're just creating a VM (for now).

Terraform installation has been explained countless times online for whatever operating system you're using, so I assume you know how to install it (or how to google: terraform install<insert operating system here>).

After installation, you need to install a provider so that it can communicate with the Proxmox API server. Fortunately, there is a provider that is actively being developed for this use.

Proxmox Vendor

You can find the Proxmox provider for TerraformHere.

The project is under active development and runs without problems most of the time (99% of the time always works).

To install it, just run the following commands to install the dependencies:

go get -v get -v install -v github. com/Telmate/terraform-provider-proxmox/cmd/terraform-provider-proxmoxgo install -v

Finally, copy the executables that the compilation gave us to the path directory, in my case:

(Video) Create VMs on Proxmox in Seconds!

sudo cp $GOPATH/bin/terraform-provider-proxmox /usr/local/bin/ sudo cp $GOPATH/bin/terraform-provider-proxmox /usr/local/bin/

Terraform Project

Now you can start with the Terraform project and the project definitions.
We will use a directory structure like this:


Just a single file. Remember this can be as complex or as simple as you need it to be.

project definition

Darinmain.tffile, you must first set up the connection profile for the Proxmox node. If you have a cluster, any of the nodes will do:

Anbieter "proxmox" { pm_api_url = "https://$PROXMOXSERVERIP:8006/api2/json" pm_user = "[Email Protected]" pm_password = "$SUPERSECRETPASSWORD" pm_tls_insecure = "true"}

Remember to change the $PROXMOXSERVERIP and $SUPERSECRETPASSWORD variables in the example.

SSH key

Since you're using a cloud-init image (if you've opted for Debian's official template image), it's set up for passwordless login, so you need to define an SSH key to install on the VM:

variable "ssh_key" { default = "#INSERTSSHHPUBLICKEYHERE"}

Wo$INSERTSSHHPUBLICKEYHIERis the public SSH key of your Super Amazing laptop.

Now you can define the VM yourself.


Below these definitions, we can start defining our VM:

Ressource "proxmox_vm_qemu" "proxmox_vm" { count = 1 name = "tf-vm-${count.index}" target_node = "$NODETOBEDEPLOYED"clone = "debian-cloudinit"os_type = "cloud-init" cores = 4 sockets = "1" cpu = "host" memory = 2048 scsihw = "virtio-scsi-pci" bootdisk = "scsi0"disk { id = 0 size = 20 type = "scsi" storage = "data2" storage_type = "lvm" iothread = true }network { id = 0 model = "virtio" bridge = "vmbr0" }lifecycle {ignore_changes = [ network, ] }# Cloud Init Settings ipconfig0 = "ip=${count.index + 1}/24, gw="sshkeys = <<EOF ${var.ssh_key} EOF}

Remember to change those$NODETOBEDEPLOYEDEntry for the node name on which the VM is deployed and thelvm-thinAccess to the storage resource you are using.

Let's explain the resource definition. The main entries to consider are:

count <- This specifies the number of VMs to create name <- This specifies the VM name, "${count.index}" allows you to create more than one VM and it only counts from there, e.g. E.g.: tf-vm -1, tf-vm-2, tf-vm-3 etc. Cores <- The number of cores the VM will have Memory <- The amount of RAM the VM will have Disk < - The disk definitions for the VM, scale the size <- The network bridge definition to use.ipconfig0 <- The IP for the VM, the "${count.index}" allows you to have more than one VM to create and it is only counted from then on, e.g.,, etc.

Running Terraform

Terraform uses 3 main phases to run:

  • Init - This step allows Terraform to initialize and download the required plugins to run
  • Plan - This step performs the planning for the deployment using the tf file you defined. It focuses on the calculation for deployment and conflict resolution, if there is such a conflict, it shows you all the changes, additions and deletions that need to be done.
  • Apply - After the planning phase, this is the phase where the changes are applied to the infrastructure. It will provide you with a summary of the changes, additions and/or deletions to be made and ask you to confirm that you accept those changes.


In the project folder, run:


As already mentioned, Terraform will be initialized and the required plugins for the project will be installed. The output should look like this:

(Video) Tuesday Tech Tip - Automating Proxmox with Ansible and Terraform

terraform initInitializing backend...Initializing provider plugins...Terraform has been successfully initialized!You can now start working with Terraform. Try running terraform plan to see any changes required by your infrastructure. All Terraform commands should now work. If you ever set or change modules or the backend configuration for Terraform, run this command again to reinitialize your working directory. If you forget this, other commands will recognize it and remind you if necessary.

The plan

This step takes care of any calculations that need to be performed and resolving any conflicts with the infrastructure that may already be deployed.

[Email Protected]:~$ terraform planRefreshing Terraform state in-memory before plan...The updated state is used to compute this plan, but is not persisted in local or remote state storage.------------ --- ------------------------------------------------ --- -------An execution plan has been generated and is shown below. Resource actions are indicated with the following icons: + createTerraform performs the following actions: # creating proxmox_vm_qemu.proxmox_vm[0] + resource "proxmox_vm_qemu" "proxmox_vm" { + agent = 0 + balloon = 0 + boot = "cdn" + bootdisk = "scsi0" + clone = "debian-cloudinit" + clone_wait = 15 + cores = 4 + cpu = "host" + force_create = false + full_clone = true + hotplug = "network,disk,usb" + id = (known after apply) + ipconfig0 = "ip=,gw=" + memory = 2028 + name = "tf-vm-0" + numa = false + onboot = true + os_type = "cloud-init" + preprovision = true + scsihw = "virtio-scsi-pci" + sockets = 1 + ssh_host = (known after apply) + ssh_port = (known after apply) + sshkeys = <<~EOT ssh-rsa ... EOT + target_node = "pmx-01" + vcpus = 0 + vlan = -1+ disk { + backup = false + cache = "none" + format = "raw" + id = 0 + iothread = true + mbps = 0 + mbps_rd = 0 + mbps_rd_max = 0 + mbps_wr = 0 + mbps_wr_max = 0 + replica = false + size = "20" + st orage = "data2 " + storage_type = "lvm" + type = "scsi" }+ network { + bridge = "vmbr0" + firewall = false + id = 0 + link_down = false + model = "virtio" + queues = -1 + rate = - 1 + tag = -1 } }Plan: 1 to add, 0 to change, 0 to destroy. ----------------------------------------------------------This plan was saved under: planfileTo perform exactly these actions, run the following apply command: terraform apply "planfile"

The plan says that a new resource will be created on the target node: pmx-01 (that's the node I use in my lab).

After you've reviewed the plan and everything seems fine, apply it.


To apply the Terraform plan, simply run:

apply terraform

This will give you the summary of the plan and ask you to confirm. Type in: Yes and it will place its bid.

When it's done, the output should look like this:

[Email Protected]:~$ terraform complete! Resources: 1 added, 0 changed, 0 destroyed. The state of your infrastructure has been saved in the path below. This state is required to modify and destroy your infrastructure, so keep it safe. To check the full state, use the terraform show command. State path: terraform.tfstate

Final Thoughts

This example should serve as a starting point for Terraform to interact with Proxmox.

Take into account that you can destroy the VM by changing the number tomain.tfZero out the file and go through the planning and application phases.

You can share those toomain.tfFile into different files so it's more organized if you decide to expand the infrastructure with different machine role definitions and different configurations for each of them.

I also uploaded the file to my GitHubHereif you just want the file.

Thank you for reading.

New additions

As some people have reported, there might be some problems installing the proxmox plugin on their machines.

I have a Docker image set up and ready for it. The repo is located at:

(Video) Perfect Proxmox Template with Cloud Image and Cloud Init

And here is the link to the image in Docker's public registry:


How do I use terraform with proxmox? ›

Creating the Proxmox user and role for terraform

Log into the Proxmox cluster or host using ssh (or mimic these in the GUI) then: Create a new role for the future terraform user. Create the user "terraform-prov@pve" Add the TERRAFORM-PROV role to the terraform-prov user.

What is error 400 parameter verification failed? ›

The error means that one of the parameters you're setting is not allowed/formatted properly, but since it is not clear which parameters are set by proxmox-api-go , enabling debugging output as described in [1] might be helpful.

Where are proxmox VM configs stored? ›

The /etc/pve/qemu-server/<VMID>. conf files stores VM configuration, where "VMID" is the numeric ID of the given VM.

How do I change my VM storage on proxmox? ›

Select Proxmox VM -> Hardware -> Hard Disk (scsi0).

Click the "Disk Action" drop down box and choose "Move Storage" from the drop down box. In the next window, select the newly added storage box for the VM from "Target Storage" drop-down box and click "Move Disk" option.

How do I deploy a virtual machine using Terraform? ›

  1. Initialize Terraform. Run terraform init to initialize the Terraform deployment. ...
  2. Create a Terraform execution plan. Run terraform plan to create an execution plan. ...
  3. Apply a Terraform execution plan. Run terraform apply to apply the execution plan to your cloud infrastructure. ...
  4. Verify the results.
May 27, 2022

How do you automate with Terraform? ›

Automated Terraform CLI Workflow
  1. Initialize the Terraform working directory.
  2. Produce a plan for changing resources to match the current configuration.
  3. Have a human operator review that plan, to ensure it is acceptable.
  4. Apply the changes described by the plan.

How do I overcome 400 error? ›

Quick and Easy Ways to Fix a 400 Bad Request Error
  1. Force Refresh the Page.
  2. Check the Requested URL.
  3. Test Other Websites.
  4. Clear Browser Cookies.
  5. Try a Different Browser.
  6. Deactivate Browser Extensions.
  7. Clear Your DNS Cache.
  8. Restart Device.

How do I get rid of error 400? ›

How to Fix a 400 Bad Request Error
  1. Double Check the Domain Address. ...
  2. Search the Keyword. ...
  3. Clear Browser Cache or Cookies. ...
  4. Turn Off Browser Extensions. ...
  5. Check the File Size. ...
  6. Flush DNS Cache. ...
  7. Contact the Site Owner to Report the Error. ...
  8. Restart Your PC and Other Hardware.

How do I fix 400 there was a problem with your request? ›

How to Fix 400 Bad Request Error?
  1. Check the Submitted URL.
  2. Clear Browser Cache.
  3. Clear Browser Cookies.
  4. Check if File Upload Exceeds the Server Limit.
  5. Clear DNS Cache.
  6. Deactivate Browser Extensions.
Feb 24, 2023

How do I check my VM configuration? ›

Step 1: Check the virtual machine configuration versions
  1. On the Windows desktop, click the Start button and type any part of the name Windows PowerShell.
  2. Right-click Windows PowerShell and select Run as Administrator.
  3. Use the Get-VMcmdlet. Run the following command to get the versions of your virtual machines.
Jan 7, 2022

Where do I put ISO files on Proxmox? ›

Proxmox makes uploading your ISO easy to achieve directly from the UI. To begin, click local from the side panel on the left-hand side of your screen. Next, under the "Content" section, click the Upload button at the top of the screen.

Does Proxmox support Docker? ›

It is not recommended to run docker directly on your Proxmox VE host. If you want to run application containers, for example, Docker images, it is best to run them inside a Proxmox Qemu VM.

How much memory should I allocate to VM? ›

Create New Virtual Machine

VirtualBox recommends that the memory size be at least 512MB, however, the more memory you make available to the VM, the smoother and more powerful it will be. As a rule of thumb, 1/4 of the amount of memory you have on your computer should be just fine.

How much memory should I allocate to a VM? ›

VM Memory Usage
Memory Allocated to the Virtual MachineAmount of Overhead Needed
Up to 512 MBUp to 40 MB
Up to 1 GBUp to 50 MB
Up to 2 GBUp to 70 MB

How do I increase VM storage? ›

How to extend the volume inside the VM
  1. Right-click the VM and select Connect. Start the virtual machine and log in.
  2. Enter DISKMGMT. ...
  3. Right-click the C: drive and select Extend Volume. ...
  4. Select the available amount of space by which you want to extend the volume. ...
  5. Check that you have selected the correct settings.
Jul 9, 2019

How to create Linux VM using Terraform? ›

In this article, you learn how to:
  1. Create a virtual network.
  2. Create a subnet.
  3. Create a public IP address.
  4. Create a network security group and SSH inbound rule.
  5. Create a virtual network interface card.
  6. Connect the network security group to the network interface.
  7. Create a storage account for boot diagnostics.
  8. Create SSH key.
Sep 1, 2022

What is the command used to deploy infrastructure in Terraform? ›

Run the terraform apply command directly. This command automatically runs the terraform plan command, which creates an execution plan for the infrastructure. Upon confirmation of the proposed changes, the terraform apply command starts building the infrastructure.

How do I deploy a VM instance? ›

Deploying a container on a new VM instance

Go to the Create an instance page. Specify the VM details. In the Container section, click Deploy container. On the Configure container page, specify a container image name and configure options to run the container for your needs.

What are the most useful Terraform commands? ›

Basic Terraform commands
  • Prepare Cloud Shell.
  • Prepare the directory.
  • Apply the changes.
  • Reformat.
  • Validate.
  • Delete changes.
  • Specify the project ID.
  • What's next.

How do I deploy multiple virtual machines using Terraform? ›

Terraform: Example Code for Create Multiple Azure Linux Vms
  1. Step 1 – Install terraform. ...
  2. Step 2 – Copy a followng code into new directory in file called “” ...
  3. Step 3 – Create IAM user and assign Service Principal Access? ...
  4. Step 4 – update with following entry.
Sep 17, 2022

How do you overcome 500 internal error? ›

If You're Trying to Load a Page with a 500 Internal Server Error:
  1. Refresh the page. This might seem obvious, but if it's a temporary loading issue, you might find success if you refresh the page. ...
  2. Come back later. ...
  3. Delete your browser's cookies. ...
  4. Paste your URL into the website "Down for Everyone or Just Me."
Sep 15, 2022

What is 4xx status code? ›

The 4xx class of status code is intended for cases in which the client seems to have erred. Except when responding to a HEAD request, the server SHOULD include an entity containing an explanation of the error situation, and whether it is a temporary or permanent condition.

Is 400 error client or server? ›

The HyperText Transfer Protocol (HTTP) 400 Bad Request response status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error (for example, malformed request syntax, invalid request message framing, or deceptive request routing).

What is a 400 error API? ›

The 400 Bad request status code indicates that the server was unable to process the request due to invalid information sent by the client. In other words, the client request needs modification.

What are 500 errors? ›

The HyperText Transfer Protocol (HTTP) 500 Internal Server Error server error response code indicates that the server encountered an unexpected condition that prevented it from fulfilling the request.

Can we automate the configuration of VM? ›

When it comes to automating the configuration of a Linux VM, you can use Cloud-INIT. Cloud-INIT is a popular way of customizing a Linux VM during its initial boot. Cloud-INIT can install packages and even write files. It can also be used to configure users and security.

Where are VM config files stored? ›

VMs and associated files reside in a few default locations, in addition to a designated directory in your setup. For stand-alone hosts, default files reside in two different locations: Configuration files: C:\ProgramData\Microsoft\Windows\Hyper-V.

How do you check which VMs are running? ›

For Windows:
  1. Click Start > Run.
  2. Type msinfo32 and press Enter.
  3. In the right pane, look for System Manufacturer for 'VMware, Inc. ' If this is present, you are running within a virtualized platform, and cannot install another virtualization product on top of it.
Sep 8, 2017

How do I mount an ISO to a VM? ›

In the left navigation pane, right-click the VM and select Edit Settings. In the Virtual Machine Properties window, click CD/DVD Drive 1 and select your ISO file. In the Device Type section, select Client Device, and then click OK to save the changes. Start the VM before you mount the ISO.

How do I mount an ISO file as a virtual drive? ›

Mount the ISO File in Windows 11, 10, or 8.1

Download the ISO image, then open File Explorer and right-click on the file. From the pop-up menu, select the Mount command. This will open a virtual drive that is visible in File Explorer, from which you can install the software.

Does Proxmox use KVM or QEMU? ›

VM emulated/paravirtualized hardware

Since Proxmox VE for Virtual Machines are using KVM (+QEMU) as hypervisor, it natively (from the GUI) supports many emulated and paravirtualized hardware components such as: Motherboard chipset: i440fx or q35 (many versions)

Can I run Proxmox in a virtual machine? ›

Running Proxmox VE inside VirtualBox is possible but is not recommended for production use. Virtualizing the Proxmox VE hypervisor inside VirtualBox is usually done for development and testing purposes.

Does Proxmox use GPU? ›

Configuring Proxmox GPU passthrough

GPU passthrough is a technology that permits the Linux kernel to present the internal PCI GPU directly to the virtual machine(VM). The device behaves as powered directly by the virtual machine, and the virtual machine detects the PCI device as if it were physically connected.

How many VMs can I run with 16GB RAM? ›

16 GB RAM is not a big amount. A maximum of 4 VMs should be possible, but in such a case each system did not have an own processor, if there is a heavy load on the VMs this did not work very well. Why core of a processor boost our computer performance?

Is 8GB RAM enough for running virtual machines? ›

As much as you give it. With virtual machines RAM is user configurable. For decent performance at least 8GB would be recommended if you have a computer with 16GB or more. Linux in general works best with at least 4GB of RAM, but it all depends on the workload.

How many cores should I give my VM? ›

A general rule of thumb is to run four virtual CPU (vCPU) VMs per physical core, but again, specific workloads may have differing requirements. Don't allocate your physical cores entirely with vCPUs.

How much RAM do I need to run multiple VMs? ›

You can run 3 or 4 basic virtual machines on a host that has 4GB of RAM, though you'll need more resources for more virtual machines. On the other end of the spectrum, you can also create large virtual machines with 32 processors and 512GB RAM, depending on your physical hardware.

What is a good initial size for virtual memory? ›

The Initial size is one and a half (1.5) x the amount of total system memory. The Maximum size is three (3) x the initial size. So let's say you have 4 GB (1 GB = 1,024 MB x 4 = 4,096 MB) of memory. The initial size would be 1.5 x 4,096 = 6,144 MB and the maximum size would be 3 x 6,144 = 18,432 MB."

How many virtual machines can run on one server? ›

More than three VMs per core causes scheduling overhead, among other issues. This doesn't mean paltry consolidation numbers, however. A high-end server using a 15-core Intel Xeon E7 processor yields 60 available cores. Ideally, it could host 180 VMs.

How do I increase my VM speed? ›

Increasing network bandwidth available to virtual machines
  1. Using additional network hardware. The easiest solution is to install additional NICs in your host server. ...
  2. Introduce virtual networks. ...
  3. Match network port use to server needs.
Feb 8, 2011

Can you give a VM more RAM? ›

Increase the amount of RAM to suit your requirements. Open the VMware vSphere Client. Right-click the Exinda Virtual Appliance, and select Edit Settings. On the Hardware tab, select Memory.

How do I use Terraform in Linux? ›

To install Terraform, find the appropriate package for your system and download it as a zip archive. After downloading Terraform, unzip the package. Terraform runs as a single binary named terraform . Any other files in the package can be safely removed and Terraform will still function.

How do you apply Terraform? ›

Apply configuration
  1. Lock your project's state, so that no other instances of Terraform will attempt to modify your state or apply changes to your resources. ...
  2. Create a plan, and wait for you to approve it. ...
  3. Execute the steps defined in the plan using the providers you installed when you initialized your configuration.

How do I run Terraform commands? ›

The usual way to run Terraform is to first switch to the directory containing the . tf files for your root module (for example, using the cd command), so that Terraform will find those files automatically without any extra arguments.

How do I run a Terraform module? ›

How To Use Terraform Modules
  1. Step 1 – Declare that you want to use Terraform modules. To use a Terraform module, you have to first declare that you wish to use it in your current configuration. ...
  2. Step 2 – Declare Module Outputs. ...
  3. Step 3 – Taint Terraform Modules. ...
  4. Step 4 – Test Modules.
Aug 13, 2021

What are Terraform commands? ›

Basic Terraform commands
  • On this page.
  • Prepare Cloud Shell.
  • Prepare the directory.
  • Apply the changes.
  • Reformat.
  • Validate.
  • Delete changes.
  • Specify the project ID.

Can Terraform run a script? ›

The bash script will be executed from Terraform as a provisioner. Executing a bash script from Terraform can be used to configure the newly created server or for any other purpose.

Where can I write Terraform scripts? ›

Terraform can create infrastructure across a wide variety of platforms, or what it calls providers, including AWS, Azure, Google Cloud, DigitalOcean, and many others. You can write Terraform code in just about any text editor.

What are the three steps in Terraform? ›

The core Terraform workflow has three steps:
  • Write - Author infrastructure as code.
  • Plan - Preview changes before applying.
  • Apply - Provision reproducible infrastructure.

What is Terraform for beginners? ›

HashiCorp Terraform is an infrastructure as code tool that lets you define both cloud and on-prem resources in human-readable configuration files that you can version, reuse, and share. You can then use a consistent workflow to provision and manage all of your infrastructure throughout its lifecycle.

How can I learn Terraform fast? ›

10 Best Online Courses to learn Terraform in 2023
  1. Hashicorp Certified — Terraform Associate. ...
  2. Terraform for absolute beginners [Coursera Project] ...
  3. Terraform: From Beginner to Master with Examples in AWS [Educative] ...
  4. Deep Dive — Terraform By Ned Bellavance [Pluralsight] ...
  5. Learn DevOps: Infrastructure Automation With Terraform.

What is Terraform provisioner? ›

Terraform Provisioners are used for executing scripts or shell commands on a local or remote machine as part of resource creation/deletion. They are similar to “EC2 instance user data” scripts that only run once on the creation and if it fails terraform marks it tainted.

How do you write a Terraform script? ›

Terraform: Create Scripts and State Files with Resource Discovery
  1. Create state files for existing resources in the Console, and then add those resources to a Terraform setup.
  2. Duplicate your existing infrastructure in a new tenancy or region.
  3. Detect state drift for updated resources.
Jan 18, 2023

How do you call a script in Terraform? ›

Executing Shell Script in Terraform via Null Resource
  1. Step 1: Shell script to perform health check.
  2. Step 2: Terraform file for provision.
  3. Step 3: Initializing Terraform.
  4. Step 4: Provisioning resources.
Dec 7, 2020

How do I call a local module in Terraform? ›

Change into the directory in your terminal. Ensure that Terraform has downloaded all the necessary providers and modules by initializing it. $ terraform init Initializing modules... Downloading 4.3.

What is the difference between root module and child module in Terraform? ›

A Terraform module (usually the root module of a configuration) can call other modules to include their resources into the configuration. A module that has been called by another module is often referred to as a child module.

How do I run Terraform without prompt? ›

You can pass the -auto-approve option to instruct Terraform to apply the plan without asking for confirmation.


1. Terraform #01 Proxmox
(Sajjad Gerami)
2. Linux VM Templates in Proxmox on EASY MODE using Prebuilt Cloud Init Images! Proxmox Quick Tips
(apalrd's adventures)
3. Best Home Lab Automation Tools! Packer, Terraform, PowerShell, and Ansible
4. ProxMox CloudInit Tutorial - Roll-out VMs into production like a pro
(Gateway IT Tutorials)
5. Proxmox + terraform + cloud-init
(Игорь Смирнов)
6. Unlock All Your Virtual Machines and Services! (Proxmox)


Top Articles
Latest Posts
Article information

Author: Nathanial Hackett

Last Updated: 02/09/2023

Views: 6262

Rating: 4.1 / 5 (52 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Nathanial Hackett

Birthday: 1997-10-09

Address: Apt. 935 264 Abshire Canyon, South Nerissachester, NM 01800

Phone: +9752624861224

Job: Forward Technology Assistant

Hobby: Listening to music, Shopping, Vacation, Baton twirling, Flower arranging, Blacksmithing, Do it yourself

Introduction: My name is Nathanial Hackett, I am a lovely, curious, smiling, lively, thoughtful, courageous, lively person who loves writing and wants to share my knowledge and understanding with you.