Skip to content

0.12upgrade does not honor "-plugin-dir" #21594

@alewando

Description

@alewando

Terraform Version

0.12.1

Terraform Configuration Files

provider "aws" {
  region = "us-east-1"
}

Expected Behavior

Running 0.12upgrade against a directory that has been initialized using an external plugin directory (terraform init -plugin-dir=/path/to/plugins) should upgrade the .tf files to version 0.12 syntax.

Actual Behavior

The upgrade fails because the external plugin directory (as captured in .terraform/plugin_path) is not searched, so the provider cannot be found:

- provider.aws: no suitable version installed
  version requirements: '(any version)'
  versions installed: none

Steps to Reproduce

  1. Download the a provider plugin to an external directory (/tmp/plugins)
  2. Create a directory with a tf definition that uses that provider:
provider "aws" {
  region = "us-east=1"
}
  1. Run terraform init -plugin-dir=/tmp/plugins
  2. Run terraform 0.12upgrade -yes

Debug logs

On the initial init, the trace log shows the plugin directory being used:

2019/06/04 19:41:21 [DEBUG] checking for provider in "/tmp/plugins"
2019/06/04 19:41:21 [DEBUG] found provider "terraform-provider-aws_v2.12.0_x4"
...
2019/06/04 19:41:22 [DEBUG] found valid plugin: "aws", "2.12.0", "/tmp/plugins/terraform-provider-aws_v2.12.0_x4"

And a .terraform/plugin_path file is generated:

$ cat .terraform/plugin_path
[
  "/tmp/plugins"
]

But when the 0.12upgrade command is run, the plugin dir is not searched:

2019/06/04 19:41:22 [DEBUG] checking for provider in "."
2019/06/04 19:41:22 [DEBUG] checking for provider in "/usr/local/bin"
2019/06/04 19:41:22 [DEBUG] checking for provider in ".terraform/plugins/linux_amd64"
2019/06/04 19:41:22 [DEBUG] checking for provisioner in "."
2019/06/04 19:41:22 [DEBUG] checking for provisioner in "/usr/local/bin"
2019/06/04 19:41:22 [DEBUG] checking for provisioner in ".terraform/plugins/linux_amd64"
...
Error: error resolving providers:

- provider.aws: no suitable version installed

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions