我在本地构建了一个 google terraform provider,用于添加模式支持。当我简单地在 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 映像一起工作的方向吗?
非常感谢, 加贝斯