无法在terraform docker映像中使用本地构建的提供程序



我在本地构建了一个谷歌地形提供程序,用于添加模式支持。当我在wsl2上简单地使用带有普通Terraform安装的二进制文件,并设置像.terraformrc这样的配置时,可以毫无问题地使用提供程序二进制文件。

尽管当我尝试在terraform docker映像中使用二进制文件(在/go/bin/providers下复制二进制文件(时,即使terraform说它已经成功初始化,但没有这样的文件或目录消息,它也会失败。

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

二进制文件存在于正确的文件夹下:

/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

符号链接是在初始化期间创建的,指向正确的目标。已授予权限。

/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配置文件的路径正确:

disable_checkpoint = true
provider_installation {
filesystem_mirror {
path    = "/go/bin/providers"
include = ["*/*/*"]
}
}

看起来它应该像在本地安装中一样使用docker映像,但它不起作用。

有人能给我指一个方向吗?我在配置中缺少了什么,让二进制文件与terraform docker映像一起工作?

非常感谢,Gabesz

尝试使用CGO_ENABLED=0进行构建

最新更新