Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose Provider Version configured in the client's required_providers {} #920

Closed
SkymineGit opened this issue Feb 7, 2024 · 4 comments
Closed
Labels
enhancement New feature or request

Comments

@SkymineGit
Copy link

Module version

github.com/hashicorp/terraform-plugin-framework v1.5.0

Use-cases

I'd like to use the provider version attribute configured under the terraform required_providers {} on the client side to pass it as input attribute to an API that the provider interacts with to do what it needs to do based on the version.

The use case is to have provider versions in sync with the API it interacts in the backend, otherwise it can be that the provider schema and the backend API are out of sync in terms of attributes and theirs values and will cause failures. Multiple version of the provider can be used so I can't use only the latest version and always be in sync.

Attempted Solutions

I couldn't find anywhere in the framework the provider version configured in required_providers {}. There is a Terraform Version attribute under the provider ConfigureRequest

type ConfigureRequest struct {
    // TerraformVersion is the version of Terraform executing the request.
    // This is supplied for logging, analytics, and User-Agent purposes
    // only. Providers should not try to gate provider behavior on
    // Terraform versions.
    TerraformVersion string

I've worked around this by creating a provider configuration attribute and capturing the same version in the required_providers {} in that attribute. With this method, there is a risk of the user setting up different versions between required_providers {} and the provider configuration attribute which will cause issues with the backend API.

Proposal

I couldn't call myself even a junior go developer so it's hard for me to provide a solution but it seams innocent enough to me if exposed in the same manner as the Terraform Version approach.

@SkymineGit SkymineGit added the enhancement New feature or request label Feb 7, 2024
@chrismarget-j
Copy link

chrismarget-j commented Feb 7, 2024

Rather than collecting the constraint value (which may be configured sloppily or not at all), you could detect the actual version of the provider.

This provider does exactly that.

It works like this:

@SkymineGit
Copy link
Author

thank you very much for the guidance. That's exactly what I needed.

@austinvalle
Copy link
Member

austinvalle commented Feb 7, 2024

One additional note about the terraform -> required_providers -> version attribute is that it's a constraint and our general guidance is to define version as the minimum provider version a terraform config is known to work with.

terraform {
  required_providers {
    example_provider = {
      source  = "hashicorp/example"
      version = ">= 1.0"
    }
  }
}

If it was feasible to get this information to a provider, it wouldn't provide exactly what you're looking for unfortunately ☹️

Copy link

github-actions bot commented Mar 9, 2024

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants