I have built locally a google terraform provider for adding schema support. When I simply use the binaries with normal Terraform installation on wsl2 and setting up the configs like .terraformrc
the provider binaries can be used without any issue.
Although when I try to use the binaries in a terraform docker image (copied the binaries under /go/bin/providers
) even though Terraform says it has been successfully initialized it fails with no such files or directory message.
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
Error: Could not load plugin
Plugin reinitialization required. Please run "terraform init".
Plugins are external binaries that Terraform uses to access and manipulate
resources. The configuration provided requires plugins which can't be
located,
don't satisfy the version constraints, or are otherwise incompatible.
Terraform automatically discovers provider requirements from your
configuration, including providers used in child modules. To see the
requirements and constraints, run "terraform providers".
2 problems:
- failed to instantiate provider "registry.terraform.io/hashicorp/google"
to obtain schema: fork/exec
.terraform/providers/registry.terraform.io/hashicorp/google/3.58.0/linux_amd64/terraform-provider-google_v3.58.0_x5:
no such file or directory
- failed to instantiate provider
"registry.terraform.io/hashicorp/google-beta" to obtain schema: fork/exec
.terraform/providers/registry.terraform.io/hashicorp/google-beta/3.64.0/linux_amd64/terraform-provider-google-beta_v3.64.0_x5:
no such file or directory
The binaries are exists under the right folder:
/go/bin/providers/registry.terraform.io/hashicorp/google-beta/3.64.0/linux_amd64:
total 79768
drwxrwxrwx 1 root root 4096 Apr 29 21:43 .
drwxrwxrwx 1 root root 4096 Apr 29 21:43 ..
-rwxrwxrwx 1 root root 81661207 Apr 29 21:41 terraform-provider-google-beta_v3.64.0_x5
/go/bin/providers/registry.terraform.io/hashicorp/google/3.58.0/linux_amd64:
total 77320
drwxrwxrwx 1 root root 4096 Apr 29 21:43 .
drwxrwxrwx 1 root root 4096 Apr 29 21:43 ..
-rwxrwxrwx 1 root root 79157279 Apr 29 21:42 terraform-provider-google_v3.58.0_x5
The symlink is created during init and points to the right target. Permissions granted.
/terraform/.terraform/providers/registry.terraform.io/hashicorp/google-beta/3.64.0:
total 12
drwxr-xr-x 2 root root 4096 Apr 29 21:59 .
drwxr-xr-x 3 root root 4096 Apr 29 21:59 ..
lrwxrwxrwx 1 root root 80 Apr 29 21:59 linux_amd64 -> /go/bin/providers/registry.terraform.io/hashicorp/google-beta/3.64.0/linux_amd64
File: '/terraform/.terraform/providers/registry.terraform.io/hashicorp/google/3.58.0/linux_amd64' -> '/go/bin/providers/registry.terraform.io/hashicorp/google/3.58.0/linux_amd64'
Size: 75 Blocks: 8 IO Block: 4096 symbolic link
Device: 810h/2064d Inode: 1460422 Links: 1
Access: (0777/lrwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2021-05-04 12:07:48.516825600 +0000
Modify: 2021-04-29 21:59:20.960000000 +0000
Change: 2021-04-29 21:59:20.960000000 +0000
File: /terraform/.terraform/providers/registry.terraform.io/hashicorp/google/3.58.0/linux_amd64/terraform-provider-google_v3.58.0_x5
Size: 79157279 Blocks: 154608 IO Block: 4096 regular file
Device: 2dh/45d Inode: 1460171 Links: 1
Access: (0777/-rwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2021-05-04 12:09:45.596825600 +0000
Modify: 2021-04-29 21:42:44.000000000 +0000
Change: 2021-05-04 12:09:45.556825600 +0000
CLI config file has the right path:
disable_checkpoint = true
provider_installation {
filesystem_mirror {
path = "/go/bin/providers"
include = ["*/*/*"]
}
}
Seemingly it should work with the docker image as it does on the local installation but it isn't working.
Can someone point me to the direction what am I missing from the configuration to get the binaries work with the terraform docker image?
Many thanks, Gabesz