Terraform taking ages to download providers and download multiple times

Ever since I upgraded terraform version from 0.11 ->0.12 → 0.13. Terraform download the provider multiple time. Once at the time of plan and then at the time of apply. Previously, it use to run only once.

Second, It reverts back the aws-auth configmap and removes all the users I added. This was working fine in 0.11

Initializing provider plugins…

  • terraform.io/builtin/terraform is built in to Terraform
  • Finding hashicorp/helm versions matching “2.0.0”…
  • Finding hashicorp/local versions matching “>= 1.4.*”…
  • Finding cyrilgdn/rabbitmq versions matching “1.5.1”…
  • Finding hashicorp/template versions matching “>= 2.1.*”…
  • Finding hashicorp/random versions matching “>= 2.1., >= 2.1.”…
  • Finding mongodb/mongodbatlas versions matching “0.8.2, ~> 0.8.2”…
  • Finding hashicorp/null versions matching “>= 2.1.*”…
  • Finding cloudamqp/cloudamqp versions matching “1.9.1”…
  • Finding hashicorp/aws versions matching “3.27.0, >= 3.22.0, >= 3.22.0, >= 3.22.0, >= 3.15.*”…
  • Finding hashicorp/kubernetes versions matching “2.0.0, >= 1.11.1”…
  • Installing cloudamqp/cloudamqp v1.9.1…
  • Installed cloudamqp/cloudamqp v1.9.1 (self-signed, key ID D2F4A50F2BA2AFDC)
  • Installing hashicorp/kubernetes v2.0.0…
  • Installed hashicorp/kubernetes v2.0.0 (signed by HashiCorp)
  • Installing hashicorp/template v2.2.0…
  • Installed hashicorp/template v2.2.0 (signed by HashiCorp)
  • Installing hashicorp/random v3.1.0…
  • Installed hashicorp/random v3.1.0 (signed by HashiCorp)
  • Installing mongodb/mongodbatlas v0.8.2…
  • Installed mongodb/mongodbatlas v0.8.2 (signed by a HashiCorp partner, key ID 2A32ED1F3AD25ABF)
  • Installing hashicorp/null v3.1.0…
  • Installed hashicorp/null v3.1.0 (signed by HashiCorp)
  • Installing hashicorp/aws v3.27.0…
  • Installed hashicorp/aws v3.27.0 (signed by HashiCorp)
  • Installing hashicorp/helm v2.0.0…
  • Installed hashicorp/helm v2.0.0 (signed by HashiCorp)
  • Installing hashicorp/local v2.1.0…
  • Installed hashicorp/local v2.1.0 (signed by HashiCorp)
  • Installing cyrilgdn/rabbitmq v1.5.1…
  • Installed cyrilgdn/rabbitmq v1.5.1 (self-signed, key ID 7B380B62B35DBF67)

Hi @vrathore18,

Terraform only installs providers when you run terraform init. The terraform plan and terraform apply commands only use providers already cached in your working directory.

Are you running terraform init again before you run terraform apply? That would cause Terraform to re-initialize the working directory, but that shouldn’t be necessary if you already have the directory initialized from the first run of terraform init.

Yes. that is what my understand was. I have a makefile which do this steps:

terraform init
terraform apply

Providers are downloading on init steps and again in apply after successfully configured the backend “s3”

Hi @vrathore18,

I believe that in a later release Terraform reverted to the previous behavior of only downloading providers that aren’t already present in the local directory, so if you keep upgrading to v0.14 and then to v0.15 I think you will see Terraform return to the behavior you’re expecting here, assuming I’m understanding correctly how you’ve built your automation.