Terraform tries to load old defunct provider - postgresql

Attempting to use cyrilgdn/postgresql provider but terraform continues to attempt to load hashicorp/postgresql, this causes init to fail. Currently using terraform 1.0.0, although the problems happens on 14.1 too - have not upgraded from 12.x, always run 14.1 or newer on this work.
I've reduced the code to the below, nothing else in this folder and still get the problem
terraform {
required_version = ">= 0.14.1"
required_providers {
postgres = {
source = "cyrilgdn/postgresql"
version = ">=1.13.0"
}
}
}
provider "postgresql" {
host = "TBC"
port = 5432
username = "TBC"
password = "TBC"
}
init reports:
Initializing provider plugins...
- Finding cyrilgdn/postgresql versions matching ">= 1.13.0"...
- Finding latest version of hashicorp/postgresql...
- Installing cyrilgdn/postgresql v1.13.0...
- Installed cyrilgdn/postgresql v1.13.0 (self-signed, key ID 3918DD444A3876A6)
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/postgresql: provider registry registry.terraform.io does not have a
provider named registry.terraform.io/hashicorp/postgresql
terraform providers reports
Providers required by configuration:
.
├── provider[registry.terraform.io/hashicorp/postgresql]
└── provider[registry.terraform.io/cyrilgdn/postgresql] >= 1.13.0
How can I stop it trying to find hashicorp/postgresql ?

It should be postgresql, not postgres:
terraform {
required_version = ">= 0.14.1"
required_providers {
postgresql = {
source = "cyrilgdn/postgresql"
version = ">=1.13.0"
}
}
}

Related

To enable preview feature of azure resource provider

I would like to enable an azure preview feature via terraform. I have configured skip provider registration but when I tried to apply still get provider already exists error. I have to import manually as a workaround.
QUERY?:
do we must import manually to avoid provider exist error when register preview feature?
as I already define skip registration but seems it didn’t work.
Thanks!
======== configuration ========
Configure the Azure provider
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm”
version = “~> 2.99"
}
}
required_version = “>= 1.1.0”
}
provider “azurerm” {
features {}
skip_provider_registration = true
}
resource “azurerm_resource_provider_registration” “example” {
name = “Microsoft.Network”
feature {
name = “AFWEnableNetworkRuleNameLogging”
registered = true
}
}
have configured to skip provider registration but when I tried to apply still get provider already exists.
======== error log
terraform apply main.tf plan
azurerm_resource_provider_registration.example: Creating…
╷
│ Error: A resource with the ID. “/subscriptions/xxxx-xxxx/providers/Microsoft.Network” already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for “azurerm_resource_provider_registration” for more information.
Any solution on the above requirement to enable the preview feature of the corresponding namespace resource provider.
If the Terraform statefile already contains the relevant providers, we should import it first before making any changes. Then only Terraform will read the respective changes from statefile.
Step1:
Add below code in provider tf and main tf as below
provider tf file
terraform {
required_version = ">= 1.1.0"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 2.99"
}
}
}
provider "azurerm" {
features {}
skip_provider_registration = true
}
main tf file as follows
resource "azurerm_resource_provider_registration" "example" {
name = "Microsoft.Network"
feature {
name = "AFWEnableNetworkRuleNameLogging"
registered = true
}
}
Step2:
Run bellow commands
terraform plan
Run below command
terraform apply -auto-approve
NOTE:
if error saying its "already exists - to be managed via Terraform this resource needs to be imported into the State." then please run below command to import the respective service via terraform
terraform import azurerm_resource_provider_registration.example /subscriptions/************************/providers/Microsoft.Network
Output as follows:
Step3:
run below commands
terraform plan
terraform apply -auto-approve

Install kubeflow using terraform - juju needed?

There is need to installl kubeflow using terraform. As I understand 'juju' must be installed, so I found juju provider on terraform: https://registry.terraform.io/providers/juju/juju/latest
I use below code into terraform:
terraform {
required_version = "> 1.3.0"
required_providers {
kubernetes = {
source = "hashicorp/kubernetes"
version = "2.16"
}
juju = {
source = "juju/juju"
version = "0.4.3"
}
}
backend "local" {
path = "/tmp/terraform.tfstate"
}
}
provider "juju" {
# controller_addresses = "localhost:8080"
username = "jujuuser"
password = "password1"
}
I don't know what should be the controller_addresses so i get:
Error: host addresses: cannot parse "" as address:port: missing port in address not valid
and I have some problems with certificate x509 but first the controller_addresses problem need to be solved.
Maybe someone know how to handle to install kubeflow the easier way.
Terraform will be used on local machine for tests and after on premises server.
The main thing for the task is to install kubeflow using terraform.

The provider provider.helm does not support data source "helm_repository"

I am able initialize the terraform
provider.helm: version = "~> 2.0"
provider.kubernetes: version = "~> 2.0"
provider.null: version = "~> 3.1"
Terraform has been successfully initialized!
using terraform Terraform v0.12.20
but when I run "terraform apply" I am getting this error "The provider provider.helm does not support data source "helm_repository"."
here is my configuration.
data "helm_repository" "helm-charts-all" {
name = "helm-charts-all"
url = var.helm_repo
username = ""
password = ""
}
Helm repository datasource has been removed in version 2.0.
https://registry.terraform.io/providers/hashicorp/helm/1.2.4/docs/data-sources/repository
Data Source: helm_repository
Warning: This resource is deprecated and will be removed in the next major version.

Terraform running in Azure Pipeline attempting to install azcli provider

I'm running Terraform in an Azure Pipeline (something I have experience of doing) and for some reason the init step is attempting to install a provider for azcli, which I don't think exists. This does not happen when I run Terraform on my local machine.
My providers file is:
terraform {
required_version = ">=0.13"
backend "azurerm" {
container_name = "tfstate"
key = "terraform.tfstate"
}
required_providers {
grafana = {
source = "grafana/grafana"
version = "=1.5.0"
}
}
}
This is the error I'm seeing:
I'm not sure why Terraform is trying to install the azcli provider; I don't think it even exists. Has anyone seen this before?
Terraform searches directly and indirectly for providers when initialization. It is possible there is a mistake in the resource name or provider definition. Search your codebase for azcli.
▶ cat .\main.tf
resource "azcli_test" "test" {
test = "true"
}
~\projects\test\t5 ◷ 10:10:21 AM
▶ C:\Users\pearcec\bin\terraform init
Initializing the backend...
Initializing provider plugins...
- Finding latest version of hashicorp/azcli...
Error: Failed to install provider
Error while installing hashicorp/azcli: provider registry
registry.terraform.io does not have a provider named
registry.terraform.io/hashicorp/azcli
or
~\projects\test\t5 ◷ 10:10:23 AM
▶ cat .\main.tf
provider "azcli" {
features {}
}
~\projects\test\t5 ◷ 10:13:41 AM
▶ C:\Users\pearcec\bin\terraform init
Initializing the backend...
Initializing provider plugins...
- Finding latest version of hashicorp/azcli...
Error: Failed to install provider
Error while installing hashicorp/azcli: provider registry
registry.terraform.io does not have a provider named
registry.terraform.io/hashicorp/azcli
or
▶ cat .\main.tf
terraform {
required_providers {
azcli = {
source = "-/azcli"
}
}
}
~\projects\test\t5 ◷ 10:16:09 AM
▶ C:\Users\pearcec\bin\terraform init
Initializing the backend...
Initializing provider plugins...
- Finding latest version of -/azcli...
Error: Failed to query available provider packages
Could not retrieve the list of available versions for provider -/azcli:
provider registry registry.terraform.io does not have a provider named
registry.terraform.io/-/azcli

Invalid Slug version in terraform

I am trying to create a kubernetes cluster with terraform but it shows me an error, I changed the value of the version on different occasions but it did not work.
resource "digitalocean_kubernetes_cluster" "lox" {
name = "lox"
region = "nyc1"
version = "1.13.4-do.0"
node_pool {
name = "worker-pool"
size = "s-1vcpu-2gb"
node_count = 2
}
This is the error:
Error: Error creating Kubernetes cluster: POST https://api.digitalocean.com/v2/kubernetes/clusters: 422 validation error: invalid version slug
on 01-cluster.tf line 1, in resource "digitalocean_kubernetes_cluster" "lox":
1: resource "digitalocean_kubernetes_cluster" "lox" {
how can i solve it?
Use below command to grab the latest and valid version slug and use it in version
doctl kubernetes options versions
The version you're setting does not exist.
Check here: https://www.digitalocean.com/docs/kubernetes/changelog/ for all the versions available, or using the doctl command line.
If you're targeting 1.13, you may use 1.13.12-do.8 as the version, released on 22/06/2020.
i wasn't able to find the version in changelog, found it here https://slugs.do-api.dev/ (tab "Kubernetes versions")
doctl kubernetes options versions
Slug Kubernetes Version Supported Features
1.24.4-do.0 1.24.4 cluster-autoscaler, docr-integration, ha-control-plane, token-authentication
1.23.10-do.0 1.23.10 cluster-autoscaler, docr-integration, ha-control-plane, token-authentication
1.22.13-do.0 1.22.13 cluster-autoscaler, docr-integration, ha-control-plane, token-authentication