Error when installing terraform cloudstack provider plugin

Terraform Version

Terraform v1.6.3 on linux_amd64

Terraform Configuration Files

…terraform config…

provider.tf
terraform {
required_version = “>= 0.13”
required_providers {
cloudstack = {
source = “Terraform Registry
version = “~> 0.4.0”
}
}
}

provider “cloudstack” {
api_url = “”
api_key = “”
secret_key = “”
}

Debug Output

terraform --version Terraform v1.6.3 on linux_amd64 terraform init -reconfigure
Initializing the backend…
Successfully configured the backend “http”! Terraform will automatically
use this backend unless the backend configuration changes.
Initializing provider plugins…

Expected Behavior

what terraform configuration I have done by using that configuration my on instance should be provisioned on Cloudstack

Actual Behavior

when I’m running terraform init my required provider plugin is not installed properly when I’m running the same cmd again and again it works some but most of the time I’m facing an error

terraform --version Terraform v1.6.3 on linux_amd64 terraform init -reconfigure
Initializing the backend…
Successfully configured the backend “http”! Terraform will automatically
use this backend unless the backend configuration changes.
Initializing provider plugins…

Steps to Reproduce

terraform init
terraform plan
terraform apply

Hi @andwivedi74,

The packages for this provider are hosted on GitHub’s CDN and so this seems to be a problem with Terraform on your system connecting to your nearest GitHub CDN endpoint.

Unfortunately it’s not really possible to remotely debug situations like this, because I can’t run tests from your machine to understand why the connection might be failing or completing very slowly.

I would suggest trying from a different computer on a different network – for example, a cloud VM in a different region – to see if you see a different result. If you do, then the question will be what is different about the network connection or computer you tried this on first.

@andwivedi74

Hi,

If you are able to download the provider binary (zipped) from the internet, you can install the provider from local directory (offline) rather than installing online.

You can unzip the tarball to a default directory for the provider and then run terraform init.

For GNU/Linux distros, the default directory usually start with /usr/share/terraform/plugins/registry.terraform.io/...

For example, in one of my projects - GitHub - zhenrong-wang/hpc-now: A cross-platform, multi-cloud High-Performance Computing platform , my command line tool downloads the providers (aws, azurerm, gcp …) from https://releases.hashicorp.com and unzip it to the local directories in order to avoid the online installation.

For cloudstack-provider version 0.4.0, I think you can try:

  1. Download the tarball from github: Release v0.4.0 · apache/cloudstack-terraform-provider (github.com)

  2. sudo mkdir -p /usr/share/terraform/plugins/registry.terraform.io/cloudstack/cloudstack/0.4.0/linux_amd64/

  3. unzip TARBALL_DOWNLOADED.zip -d /usr/share/terraform/plugins/registry.terraform.io/cloudstack/cloudstack/0.4.0/linux_amd64/

  4. Try terraform init command

Hope my comment helps.

Zhenrong WANG