-2

Due to this problem it looks like for providers you have to get a current version of the SDK (2.4.4 at time of post). This post has a lot of info on how to import a specific version of a package but surely every single provider writer isn't manually pulling the most recent version of the SDK (or are they)?

I'm new to Go/Terraform so maybe I'm missing something obvious but the providers I've found (including the official example) have something like:

import(
    "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
    "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
    "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)

The current version is not 2 - it is 2.4.4. Now I know those are local paths but what confuses me is when I run something like go get it goes and pulls those down for me. I tried doing:

"github.com/hashicorp/terraform-plugin-sdk/v2.4.4/helper/schema"

but go get very much doesn't like that. How is go get finding those package versions? Is there an import syntax that just gets me the latest build or allows me more granularity? I haven't found a good way to tell what version of the SDK I have after running go get but based on this error message:

Error

it looks like I have 2.0 because that error is, as I understand it, fixed in newer versions of the SDK.

Grant Curell
  • 1,321
  • 2
  • 16
  • 32

1 Answers1

0

I figured it out. The behavior is controlled by the go.mod file.

In there you'll find:

require (
    github.com/hashicorp/terraform-plugin-sdk v1.14.0 // indirect
    github.com/hashicorp/terraform-plugin-sdk/v2 v2.0.1

As mentioned by @JimB the v2 is the major version for the plugin. v2.0.1 are GitHub tags. Changing this to v2.4.4 obtains the desired behavior.

Grant Curell
  • 1,321
  • 2
  • 16
  • 32