hashicorp / terraform-provider-tfe

Official HCP Terraform and Terraform Enterprise provider, maintained by HashiCorp. Provision HCP Terraform or Terraform Enterprise - with Terraform!
https://registry.terraform.io/providers/hashicorp/tfe
Mozilla Public License 2.0
167 stars 157 forks source link

[FR] Create resources for managing Providers in the Registry #584

Open straubt1 opened 2 years ago

straubt1 commented 2 years ago

Use-cases

As a TFE self-managed Customer, have the ability to manage providers in the registry with Terraform.

Attempted Solutions

There are several API calls that are required to make this work, but require a fair bit of custom coding.

Proposal

Having a Terraform Provider to support this would remove the need for self managed code to manage these resources.

Basic framework of how this might work.

resource "tfe_registry_provider" "random" {
  name      = "random"
  namespace = "my-org-name"
}

resource "tfe_registry_provider_version" "random" {
  name       = "random"
  namespace  = "my-org-name"
  version    = "3.1.2"
  shasums    = file("SHA256SUMS")
  shasumssig = file("SHA256SUMS.sig")
  gpg_key_id = "51845454656465465"
}

resource "tfe_registry_provider_version_platform" "random_linux" {
  name       = "random"
  namespace  = "my-org-name"
  version    = "3.1.2"
  os         = "linux"
  arch       = "amd64"
  binary     = "./terraform-provider-random_3.1.2_linux_amd64.zip"
}

resource "tfe_registry_provider_version_platform" "random_darwin" {
  name       = "random"
  namespace  = "my-org-name"
  version    = "3.1.2"
  os         = "darwin"
  arch       = "amd64"
  binary     = "./terraform-provider-random_3.1.2_darwin_amd64.zip"
}
sebasslash commented 2 years ago

πŸ‘‹ Thanks for submitting this FR! I think this certainly doable, but it would present some novel functionality to the provider that requires some internal discussion on the best approach.

I don't imagine many customers will be including the binary with their configuration, so we'd most likely have to add support to fetch the zip from some remote source, adding complexity if the source is private.

I'll create a ticket for investigation πŸ‘

straubt1 commented 2 years ago

I had similar thoughts as well @sebasslash but figured I would add here to see what the community need was, and allow you all to determine if it was a good idea.

km274 commented 2 years ago

Hey @sebasslash, just commenting to say that I would also love to see this functionality added to the provider, and I'm interested in helping with the implementation as well.

To your point about the added complexity resulting from having to pull the provider binary from some remote source - maybe we could start with a locally-sourced binary like in @straubt1 's example and then add in the ability to pull from a remote source later on? I'm coming at it from the viewpoint that even if it means storing the binaries together with the configuration, I would rather be able to manage the providers through first-class Terraform resources than through custom logic and curl calls.😁

straubt1 commented 2 years ago

@kippmorris7 This is not the solution you are looking for, but might help in the interim. https://tfx.rocks/commands/registry_provider/#tfx-registry-provider-create

I have been developing this CLI for common TFE/TFC tasks.

ArjunDandagi commented 1 year ago

I stumbled upon this idea recently when someone in our org published to our internal registry. I would love to have this Feature. Going forward we may want to extend some publicly available providers for our usecase.

I can take this up with a mentor. πŸ™

kokosnuss commented 1 year ago

We also would love to have this Feature. @sebasslash is there anything new to say about this FR ?

tmatilai commented 12 months ago

I'm working on adding resources and data sources at least for the GPG keys and providers.

But not sure if Terraform is the best tool for managing the releases. I would like to have an easy integration with e.g. GitHub Actions for that, like with the public providers.