Closed james-masson closed 2 years ago
Thanks for creating an issue @james-masson, we'll try to address it in our next 0.3.0
release of TF Provider.
@james-masson thanks for waiting and providing a detailed minimum viable example!
I managed to reproduce the issue and found the resolution, here's the updated version of that comment:
It's likely due to your project structure. In 0.13.x
, you need to include the terraform required_providers
block in each module. This is because Terraform searches for implicitly used providers by default within its own hashicorp
namespace. Any providers outside of that namespace, such at the Confluent Cloud provider, will require explicit specification.
E.g.,
➜ test cat run/main.tf
terraform {
required_providers {
confluentcloud = {
source = "registry.terraform.io/confluentinc/confluentcloud"
version = "0.2.0"
}
}
}
provider "confluentcloud" {}
module "test" {
source = "../module"
}
and
➜ test cat module/main.tf
# Adding required_providers block in each module
terraform {
required_providers {
confluentcloud = {
source = "registry.terraform.io/confluentinc/confluentcloud"
version = "0.2.0"
}
}
}
resource "confluentcloud_service_account" "test-sa" {
display_name = "test_sa"
description = "description for test_sa"
➜ run terraform init
Initializing modules...
- test in ../module
Initializing the backend...
Initializing provider plugins...
- Finding confluentinc/confluentcloud versions matching "0.2.0"...
- Installing confluentinc/confluentcloud v0.2.0...
- Installed confluentinc/confluentcloud v0.2.0 (signed by a HashiCorp partner, key ID D4A2B1EDB0EC0C8E)
Partner and community providers are signed by their developers.
If you'd like to know more about provider signing, you can read about it here:
https://www.terraform.io/docs/plugins/signing.html
Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
➜ run terraform providers
Providers required by configuration:
.
├── provider[registry.terraform.io/confluentinc/confluentcloud] 0.2.0
└── module.test
└── provider[registry.terraform.io/confluentinc/confluentcloud] 0.2.0
Please let me know if that helps!
The author of the issue reacted with a 👍 so I think it's OK to close the issue.
Hi,
I'm trying to write a simple reusable module using this provider.
However, it looks like the provider/terraform seems to detect the wrong provider path only when it's used inside a module.
Structure
consuming the module
provider "confluentcloud" {}
module "test" { source = "../module" }
resource "confluentcloud_service_account" "test-sa" { display_name = "test_sa" description = "description for test_sa" }
jmasson@tp13 ~/workspace/test/run $ terraform init Initializing modules...
Initializing the backend...
Initializing provider plugins...
Partner and community providers are signed by their developers. If you'd like to know more about provider signing, you can read about it here: https://www.terraform.io/docs/cli/plugins/signing.html ╷ │ Error: Failed to query available provider packages │ │ Could not retrieve the list of available versions for provider hashicorp/confluentcloud: provider registry registry.terraform.io does not have a provider named registry.terraform.io/hashicorp/confluentcloud │ │ Did you intend to use confluentinc/confluentcloud? If so, you must specify that source address in each module which requires that provider. To see which modules are currently depending on │ hashicorp/confluentcloud, run the following command: │ terraform providers
jmasson@tp13 ~/workspace/test/run $ terraform providers
Providers required by configuration: . ├── provider[registry.terraform.io/confluentinc/confluentcloud] 0.2.0 └── module.test └── provider[registry.terraform.io/hashicorp/confluentcloud]