Attempting to get Terraform to work on windows 10 64 bit, using the Virtualbox provider plugin listed here (https://github.com/terra-farm/terraform-provider-virtualbox). I've verified that the plugin exists in %APPData%/terraform.d/plugins/windows_amd64 but it says it's not there. Have tried the following with no luck
None have worked. It acts as if the folder it says to place the plugin, and where it's looking are mismatched, but I doubt something like that would have made it to release, so I'm at a loss as to why it's not seeing the plugin.
Terraform is the latest version. Using the following in my example.tf (the only tf file in the directory that i execute terraform form)
resource "virtualbox_vm" "node" {
count = 2
name = format("node-%02d", count.index + 1)
image = "https://app.vagrantup.com/ubuntu/boxes/bionic64/versions/20180903.0.0/providers/virtualbox.box"
cpus = 2
memory = "512 mib"
user_data = file("user_data")
network_adapter {
type = "hostonly"
host_interface = "vboxnet1"
}
}
output "IPAddr" {
value = element(virtualbox_vm.node.*.network_adapter.0.ipv4_address, 1)
}
output "IPAddr_2" {
value = element(virtualbox_vm.node.*.network_adapter.0.ipv4_address, 2)
}
Note: This answer was true at the time I wrote it, but Terraform v0.13 and later have a different directory layout for provider plugins, and some different options for configuring them. For more information, see the Provider Installation section of the CLI Configuration documentation. (and note that the CLI configuration is something different than the .tf
files you use to describe your infrastructure; it contains global settings for Terraform CLI when running on your particular computer.)
Terraform looks for plugins in a number of locations, but the primary place for manually-installed plugins is in the "User Plugins Directory", which is either ~/.terraform.d/plugins
on Unix systems or %APPDATA%\terraform.d\plugins
on Windows.
The .terraform/plugins
directory is not the place to put plugins you're installing manually. That directory is managed by Terraform itself and is the location for automatically-installed plugins. If you place plugins in that directory manually, terraform init
may delete them as part of plugin installation.
Terraform also requires the provider executable to follow a particular naming scheme: terraform-provider-providername_vX.Y.Z
, where the _vX.Y.Z
part is technically optional but strongly recommended in order for version
constraints to operate correctly. On Windows in particular, the file must also have the suffix .exe
, because Terraform plugins are separate programs that Terraform will launch.
To debug Terraform's plugin discovery process, you can set the environment variable TF_LOG=debug
before you run terraform init
. In that output there will be lines like this:
2019/09/03 10:36:26 [DEBUG] checking for provider in "/home/username/.terraform.d/plugins"
If it finds any plugins in the various search paths, it will additionally produce lines like this:
2019/09/03 10:36:26 [DEBUG] found valid plugin: "example", "1.2.0", "/home/username/.terraform.d/plugins/terraform-provider-test_v1.2.0"
If there are any provider version constraints in the configuration than they must include whatever provider version you've installed. For example, with the above discovered provider that is example
v1.2.0, a version constraint like ~> 2.0.0
would exclude it from consideration, even though Terraform discovered it.
To see how provider versions are constrained by your configuration, run terraform providers
. If there are no constraints then it will just list the provider names, but if any constraints are present then they will be included in the output.