【问题标题】:terraform: "Error: Could not load plugin"terraform:“错误:无法加载插件”
【发布时间】:2021-04-29 02:55:59
【问题描述】:

使用 hashcorp 的 docker 映像运行 terraform plan 命令会导致此错误:

 $ docker run -it -v `pwd`:/terrascripts  hashicorp/terraform plan /terrascripts
Unable to find image 'hashicorp/terraform:latest' locally
latest: Pulling from hashicorp/terraform
Digest: sha256:eab63752545a0295eedc1318da1d293126cce4689bcd4b139afe816da3f6fffb
Status: Downloaded newer image for hashicorp/terraform:latest

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".

Failed to instantiate provider "registry.terraform.io/hashicorp/aws" to obtain
schema: unknown provider "registry.terraform.io/hashicorp/aws"

看起来类似于 this 问题。我使用工作空间来指代不同的环境。并且仅在将 terraform 与 docker 映像一起使用时才会发生。当使用the binary 时,它按预期工作。

在使用docker镜像hashicorp/terraform时有没有办法克服这个问题?

【问题讨论】:

  • 这个问题是怎么解决的?
  • 仍然出现错误。我会检查并确保它解决了问题,如果确实解决了问题,则将答案标记为已解决。

标签: docker terraform terraform-provider-aws


【解决方案1】:

您可以尝试使用-w 标志将工作目录设置为terrascripts

初始化

docker run -it -v `pwd`:/terrascripts -w /terrascripts  hashicorp/terraform init

计划

docker run -it -v `pwd`:/terrascripts -w /terrascripts  hashicorp/terraform plan

根据您的设置,您可能需要做更多工作以提供有效的 aws 凭据。

【讨论】:

    猜你喜欢
    • 2017-11-14
    • 1970-01-01
    • 1970-01-01
    • 2021-12-28
    • 1970-01-01
    • 1970-01-01
    • 2022-11-10
    • 2016-12-29
    • 2011-12-16
    相关资源
    最近更新 更多