Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terraform init is extremely slow #27379

Open
AlmogCohen opened this issue Dec 29, 2020 · 58 comments
Open

Terraform init is extremely slow #27379

AlmogCohen opened this issue Dec 29, 2020 · 58 comments
Labels
bug v0.13 Issues (primarily bugs) reported against v0.13 releases v0.15 Issues (primarily bugs) reported against v0.15 releases v1.0 Issues (primarily bugs) reported against v1.0 releases v1.2 Issues (primarily bugs) reported against v1.2 releases waiting for reproduction unable to reproduce issue without further information

Comments

@AlmogCohen
Copy link

AlmogCohen commented Dec 29, 2020

Terraform init takes forever and it seems like it is due to provider download. This extremely slow behaviour is consistent for the last 2 days. Working like that is hellish as I'm using terragrunt which runs the terraform init command often in my case.

Drilling down on the trace logs, I've seen that the download of https://releases.hashicorp.com/terraform-provider-aws/3.22.0/terraform-provider-aws_3.22.0_darwin_amd64.zip takes usually 1-5 minutes minimum. When I simply download this url in my browser, it never takes more than 15 seconds....usually less than 10. When I run the init command with trace logs, it is almost always takes many many minutes to finish.

I have no internet issues at ALL Screen Shot 2020-12-29 at 2 55 49 PM

Terraform Version

Terraform v0.13.5
+ provider registry.terraform.io/hashicorp/aws v3.22.0

Terraform Configuration Files

I have created only one file in my example project, backend.tf and this is the its content

terraform {
  backend "s3" {
    encrypt        = true
    key            = "staging/elastic_beanstalk/terraform.tfstate"
    profile        = "some-profile"
    region         = "us-east-1"
    bucket         = "company-terraform-state"
    dynamodb_table = "terraform-lock-table"
  }
}

Debug Output

https://gist.github.com/AlmogCohen/b8af6e33c170c393a63e126226ad7108

Crash Output

Not relevant

Expected Behavior

Terraform provider download should take as fast as it takes in the browser, and terraform init should not take 5 minutes for a very very simple terraform proejct

Actual Behavior

Terraform provider/plugin downloads takes forever

Steps to Reproduce

  1. terraform init

Additional Context

I'm using terragrunt, so the init command runs often on one of my dependency projects. It doesn't really matter for this bug report because I've run the terraform command directly in a folder which has only tf files in.

References

Not relevant

@AlmogCohen AlmogCohen added bug new new issue not yet triaged labels Dec 29, 2020
@AlmogCohen
Copy link
Author

Here is another trace log example from a project that is includes a little more pieces https://gist.github.com/AlmogCohen/19495e839bc4894d8084e9ab191e23f6

A billion of things are being downloaded, but mostly when it is requested from the hashicorp releases host, the download takes forever.

The download of https://releases.hashicorp.com/terraform-provider-aws/2.70.0/terraform-provider-aws_2.70.0_darwin_amd64.zip took almost a minute. Download of https://releases.hashicorp.com/terraform-provider-template/2.2.0/terraform-provider-template_2.2.0_darwin_amd64.zip took almost 40 seconds via the terraform init command, while via browser it took literally 2 seconds.

@danieldreier
Copy link
Contributor

Thanks for reporting this! You're right that it shouldn't be so slow. I'm running on a mac and it's not that slow for me. Can you try and do an install of terraform via homebrew? Homebrew's Terraform has cgo enabled, and I'm wondering if you're stalling on DNS resolution.

@danieldreier danieldreier added the waiting-response An issue/pull request is waiting for a response from the community label Dec 29, 2020
@AlmogCohen
Copy link
Author

AlmogCohen commented Dec 30, 2020 via email

@ghost ghost removed waiting-response An issue/pull request is waiting for a response from the community labels Dec 30, 2020
@zzn01
Copy link

zzn01 commented Dec 30, 2020

same issue here, terrafrom version is 0.13.5, installed via homebrew
hang on aws provider for very long time(10 minutes+)

- Installing -/aws v3.22.0...

@danieldreier
Copy link
Contributor

@AlmogCohen the reason I wanted to look into DNS issues is that golang uses its own DNS resolver rather than the native one, and this has caused issues in Terraform (and many other projects) that can currently only be worked around with a cgo-enabled build. However, if you're not seeing it on a homebrew build then that's probably not the issue.

Most of the Terraform Core engineering team is out until next week, so I'm just doing basic triage of urgent issues. As other folks run into this - please upvote with a 👍 rather than a comment, to help us prioritize this. I don't think this will get looked at until the team is back but if it turns out there's a more widespread issue I can call folks in.

@danieldreier
Copy link
Contributor

I went and tried to reproduce this again on my mac with the following trivial config:

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 3.0"
    }
  }
}

# Configure the AWS Provider
provider "aws" {
  region = "us-east-1"
}

My init took about 7 seconds:

time terraform init

Initializing the backend...

Initializing provider plugins...
- Finding hashicorp/aws versions matching "~> 3.0"...
- Installing hashicorp/aws v3.22.0...
- Installed hashicorp/aws v3.22.0 (signed by HashiCorp)

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.
terraform init  1.77s user 0.56s system 33% cpu 6.883 total

I do believe you that you're running into this, just wanted to clarify that I'm not able to reproduce a more widespread problem.

Can you share a traceroute to releases.hashicorp.com? Okay to obscure the first few hops for privacy, I'm just trying to get clues on what's different between our environments. Also, can you share what OS version you're running, if it's X86 vs ARM, anything interesting about your network environment like an HTTP proxy, etc?

@danieldreier danieldreier added the waiting-response An issue/pull request is waiting for a response from the community label Dec 30, 2020
@AlmogCohen
Copy link
Author

I copied your trivial config into main.tf and run time terraform init and this is the result:

Initializing the backend...

Initializing provider plugins...
- Finding hashicorp/aws versions matching "~> 3.0"...
- Installing hashicorp/aws v3.22.0...
- Installed hashicorp/aws v3.22.0 (signed by HashiCorp)

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.
terraform init  2.73s user 1.57s system 7% cpu 1:00.33 total

Just to prove the point again regarding no internet issues, I've run time wget https://releases.hashicorp.com/terraform-provider-aws/3.22.0/terraform-provider-aws_3.22.0_darwin_amd64.zip and got this:

--2020-12-31 08:19:33--  https://releases.hashicorp.com/terraform-provider-aws/3.22.0/terraform-provider-aws_3.22.0_darwin_amd64.zip
Resolving releases.hashicorp.com (releases.hashicorp.com)... 151.101.1.183, 151.101.129.183, 151.101.65.183, ...
Connecting to releases.hashicorp.com (releases.hashicorp.com)|151.101.1.183|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 42005468 (40M) [application/zip]
Saving to: ‘terraform-provider-aws_3.22.0_darwin_amd64.zip’

terraform-provider-aws_3.22.0_darwin_amd64.zip     100%[================================================================================================================>]  40.06M  10.1MB/s    in 4.7s

2020-12-31 08:19:38 (8.61 MB/s) - ‘terraform-provider-aws_3.22.0_darwin_amd64.zip’ saved [42005468/42005468]

wget   0.10s user 0.25s system 6% cpu 5.137 total

Mac specifications:
Screen Shot 2020-12-31 at 8 25 07 AM

For the traceroute, I think some Firewall drops it midway because nothing can be seen after the first few hops:

traceroute -q 1 -w 1 -m 100 releases.hashicorp.com
traceroute: Warning: releases.hashicorp.com has multiple addresses; using 151.101.1.183
traceroute to dualstack.s.shared.global.fastly.net (151.101.1.183), 100 hops max, 52 byte packets
 1   #### Removed #####
 2   #### Removed #####
 3  *
 4   #### Removed #####
 5  #### Removed #####
 6  *
 7  bb302-pt-e49-100g-hot.israelinternet.co.il (185.149.252.109)  11.057 ms
 8  10.141.226.60 (10.141.226.60)  12.209 ms
 9  10.185.180.51 (10.185.180.51)  15.525 ms
10  10.185.180.11 (10.185.180.11)  12.616 ms
11  be6037.203.rcr22.fra06.atlas.cogentco.com (149.14.210.161)  69.101 ms
12  *
13 *
.......(nothing answered here....)
97  *
98  *
99  *
100  *

@ghost ghost removed waiting-response An issue/pull request is waiting for a response from the community labels Dec 31, 2020
@pselle
Copy link
Contributor

pselle commented Jan 4, 2021

@AlmogCohen Thanks for running the timings and providing additional data.terraform init will take longer than the GET request alone.

One suggestion I have if you're running init often (not a workflow that is currently optimized), do make sure that if you can you're using provider cache settings. This should help with regard to your workflow.

On the final comments with timing, I see @danieldreier's report with ~7 seconds, and yours with ~5 seconds ... neither of these are close to the original 1-5 minutes in the original report. @danieldreier was also correct to point to CGO builds, as there are known DNS issues/traps that occur with other versions.

Would enabling the cache help your workflow?

@pselle pselle added the waiting-response An issue/pull request is waiting for a response from the community label Jan 4, 2021
@AlmogCohen
Copy link
Author

AlmogCohen commented Jan 5, 2021

@pselle Thanks for your comment. I'll look into enabling the cache later this week and respond here.

Regardless, it is important to note that the original problem still stands in place. The timing was 1 minute (and not 5 seconds like you said). If you'll take a closer look, you can see that the 5s timing is of wget. Terraform init is still 12 times slower, and from previous logs you could see that 95% of the time spent on terraform init is due to the resource download of the aws provider (which was timed as 5s via wget).

@ghost ghost removed waiting-response An issue/pull request is waiting for a response from the community labels Jan 5, 2021
@pselle
Copy link
Contributor

pselle commented Jan 5, 2021

@AlmogCohen Thanks, you're correct, I was looking at the wrong timing! It was the 1 minute.

@future-media
Copy link

future-media commented Jan 8, 2021

I have the same problem on Windows. Checking with Wireshark, I can see that the releases.hashicorp.com server starts off by accepting a TLSv1.2 connection but then gets stuck returning messages saying "ignored unknown record". It took so long that I killed it.

I was just doing the learn-terraform-aws-instance tutorial. I was able to create infrastructure once, but never again after that.

My provider has a short MTU of 1472 bytes. I think this requires servers to accept ICMP messages saying that packets are too long and must be resent with the shorter packet size. If routers are dropping ICMP packets it would be a problem. Just a thought.

@apparentlymart apparentlymart added the v0.13 Issues (primarily bugs) reported against v0.13 releases label Jan 9, 2021
@future-media
Copy link

future-media commented Jan 11, 2021

Although learn-terraform-aws-instance tutorial fails completely on my office connection as described above, it works just fine when executed from Windows Server hosted by a different provider.

Other Windows PCs in my office also fail, but someone was able to get it to work on Linux. So it's the combination of my office connection + Windows that fails.

@lmserrano
Copy link

lmserrano commented Jan 11, 2021

Something that also aggravates this issue is the fact that apparently, if you run multiple consecutive terraform init commands without any changes in the used providers nor their versions, Terraform will still proceed to install them each time:

$ terraform init
Initializing modules...

Initializing the backend...

Initializing provider plugins...
- Reusing previous version of hashicorp/random from the dependency lock file
- Reusing previous version of hashicorp/local from the dependency lock file
- Reusing previous version of hashicorp/null from the dependency lock file
- Reusing previous version of hashicorp/template from the dependency lock file
...
- Installing hashicorp/template v2.2.0...
- Installed hashicorp/template v2.2.0 (signed by HashiCorp)
- Installing hashicorp/random v3.0.0...
- Installed hashicorp/random v3.0.0 (signed by HashiCorp)
- Installing hashicorp/local v2.0.0...
- Installed hashicorp/local v2.0.0 (signed by HashiCorp)
- Installing hashicorp/null v3.0.0...
- Installed hashicorp/null v3.0.0 (signed by HashiCorp)
...

Terraform has been successfully initialized!

Enabling cache may improve the speed of this operation, but it will still take a while because in Terraform 0.14.4 it is doing all this each time, while in previous versions < 0.13.x (if I'm not mistaken) it would only download what was new or that it wouldn't have, or providers which had new versions in case their version numbers were referenced with other symbols like >.

@debu99
Copy link

debu99 commented Jan 20, 2021

this is a really bad experience when creating modules

@HsnVahedi
Copy link

I'm using terraform 0.14.5 on ubuntu. I'm experiencing the same thing. terraform init takes a lot of time. here is my main.tf:

provider "kubernetes" {
}

resource "kubernetes_deployment" "backend" {
  metadata {
    name = "backend"
    labels = {
      app = "backend"
    }
  }

  spec {
    replicas = 3

    selector {
      match_labels = {
        app = "backend"
      }
    }

    template {
      metadata {
        labels = {
          app = "backend"
        }
      }

      spec {
        container {
          image = "IMAGE"
          name  = "backend"
          port {
            container_port = 8000
          }
        }
      }
    }
  }
}

@everdark
Copy link

everdark commented May 4, 2022

same issue from Singapore on Apple M1 (macOS Monterey 12.2)

The provider is as simple as:

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "4.0.0"
    }
  }
}

provider "aws" {
  region = "ap-southeast-1"
}

and hang at

Initializing provider plugins...
- Finding hashicorp/aws versions matching "4.0.0"...
- Installing hashicorp/aws v4.0.0...

@kentwongg
Copy link

So is HashiCorp going to comment?

@libracoder
Copy link

Having same issue

@simbu21
Copy link

simbu21 commented Jun 24, 2022

I m having the same issue. Any update. Thank you.

@pintoflager
Copy link

Terraform v1.2.2
on linux_amd64

...and soooo sloooooow

@jaliagag
Copy link

jaliagag commented Jul 5, 2022

Same issue - trying caching, as recommended above
We'll see how it works

@binhoul
Copy link

binhoul commented Jul 19, 2022

Same issue...

@mrnonz
Copy link

mrnonz commented Jul 26, 2022

Same issue with Terraform v1.2.5

Interim solution is manual remove .terraform folder and run terraform init again.

@crw
Copy link
Contributor

crw commented Jul 26, 2022

@jaliagag Did caching help?

@mrnonz if you remove the .terraform folder, it completes successfully and within a reasonable amount of time? What happens if you run it again afterwards, with that folder?

@jeffery
Copy link

jeffery commented Aug 15, 2022

Had the same issue on my macOS Monterey (12.5). I Set ipv6 to Link-local only and restarted my mac which resolved the issue for me.

@lsascha
Copy link

lsascha commented Aug 15, 2022

only that it is not always possible to change network settings, like in a CI-CD Environment.

@Kaydub00
Copy link

I'm also experiencing this, @jeffery fix seemed to make it faster, but it's still pretty slow to download providers

@ChristophShyper
Copy link

I run Terraform via Terragrunt inside a Docker container. Worked perfectly for years, until M2 Macs come around.
On Intel processor typical run is 2 minutes. On M2 it's 5 minutes. Those 3 minutes are spent waiting on Terraform initialization.
Tested on MacBook Pro M2 and MacBook Air M2. Disabling IPv6 does nothing.

@apparentlymart apparentlymart added v1.0 Issues (primarily bugs) reported against v1.0 releases v1.2 Issues (primarily bugs) reported against v1.2 releases v0.15 Issues (primarily bugs) reported against v0.15 releases waiting for reproduction unable to reproduce issue without further information labels Sep 27, 2022
@apparentlymart
Copy link
Contributor

Hi all,

It isn't really clear how we can make progress on this issue, because there is no clear signal about what is causing these problems. We've seen several different theories discussed above, including:

  • Not resolving DNS records correctly on macOS, leading to problems for folks using VPNs or other kinds of split-horizon DNS.

    That was true of older versions of Terraform, but the darwin_amd64 builds have been using correct resolver for a long time now and we just released v1.3.1 which includes the same fix for darwin_arm64 (Apple Silicon) builds. Therefore I think we can safely exclude this as a possible cause for modern Terraform.

  • Internet service providers which have a small MTU for packets, therefore requiring the remote server to throttle back its packet sizes in response to ICMP notifications.

    I only see one mention of this and I don't have such a system to test with, so this one is still on the table as a possible cause but I'm not sure how to decide whether it's an actual cause. This is a tricky one because it's a hard constraint of the internet connection and so not something that can be temporarily disabled to see if it changes the outcome.

  • Some of you are using networks with filewalls or other interfering middleboxes, and have found that Terraform works better with those disabled.

    if we can narrow down a specific thing that Terraform is doing that irritates these intermediaries which isn't true of other network software then we could potentially try to address it, but these systems are typically pretty opaque about how they do their work and each works differently. We don't have direct access to any and so we'd need to rely on those who use these products to let us know exactly what Terraform is doing that violates the assumptions of these filters.

  • IPV6 problems various: it sounds like some of you have IPv6 connectivity that is measurably slower than your IPv4 connectivity, and perhaps Terraform was choosing to use IPv6 and therefore ending up with a slower transfer speed than other software.

    Some time ago we changed Terraform to use the Fast Fallback algorithm, which aims to avoid problems like this by trying both IPv4 and IPv6 simultaneously and using IPv4 if the IPv6 connection doesn't work. However, I believe that only helps if the IPv6 connection is totally unusable, and not if IPv6 is working but slower than IPv4.

As before, we believe you all that Terraform is working more slowly than some other network software when run on your computer but I'm at a loss as to what to do about it unless someone can either describe exactly why Terraform is slow for their particular situation or can describe a situation we can reproduce on our own systems to debug it ourselves. Our team is distributed across the US, Canada, and Europe with different ISPs each, but we've not been able to reproduce these problems on our systems or on the cloud platforms we have access to.

If you are able to download provider packages more effectively using software other than Terraform itself, you may benefit from setting up a local mirror of the providers you use regularly on your computer, and then setting up a custom provider installation strategy. That means you can in principle download the provider .zip packages from releases.hashicorp.com or from GitHub releases (depending on the provider) using your browser or other software and arrange them into one of the local filesystem mirror directory structures, and then Terraform will just load the provider plugins from your local disk rather than trying to install them over the network. This if course only a workaround and not a solution, but in the absence of concrete information about what causes the slow transfer rates I don't really have anything else to suggest.

If anyone does have any evidence of specific network misbehavior in Terraform, please let us know!

@AlmogCohen
Copy link
Author

AlmogCohen commented Sep 30, 2022

@apparentlymart your thorough response is very much appreciated!

For the protocol, as the original issue reporter....years have passed and I've since upgraded my Macbook, changed my address, my ISP and the terraform versions I use (now always >1.0.0 for all projects). I haven't seen the issue I reported for years now...

The fact that "it works on my machine" does not invalidate the many other reports that came in and seem to be related to the very same "stage" of the terraform init. On the other hand, I do understand how challenging it may be to take any action here to resolve the (many?) issues.

@PSanetra
Copy link

PSanetra commented Feb 8, 2023

I try to install terraform providers locally on my machine (Linux, Manjaro). Installing them is currently really slow (I usually do not use or at least initialize terraform locally, but run it from a CI, where some providers also might be cached).

I notice that slow performance only with terraform. E.g. pulling Docker images from Docker Hub is fast as usual.

I grabbed a sample provider plugin from the terraform logs and tried to download it via chrome. Here are the screenshots:

[...]
- Installing hashicorp/azurerm v2.70.0...
2023-02-08T14:34:27.971+0100 [TRACE] providercache.Dir.InstallPackage: installing registry.terraform.io/hashicorp/azurerm v2.70.0 from https://releases.hashicorp.com/terraform-provider-azurerm/2.70.0/terraform-provider-azurerm_2.70.0_linux_amd64.zip
2023-02-08T14:34:27.971+0100 [TRACE] HTTP client GET request to https://releases.hashicorp.com/terraform-provider-azurerm/2.70.0/terraform-provider-azurerm_2.70.0_linux_amd64.zip

slow_terraform_provider_download

Location: Germany
Terraform Version: 1.3.7

@nibblesnbits
Copy link

Same issue. I guess #32863 is a duplicate of this.

@queglay
Copy link

queglay commented Nov 18, 2023

I think terraform init is slow even when its working!
It adds 10 seconds every time its executed in a minimal AWS infra test example of mine and it needs to be executed every time in CI. It would be good if it had some serialisation of versions to determine if it needs to do heavy lifting or just use the existing cache and be snappier.

@jsyrjala
Copy link

jsyrjala commented Nov 20, 2023

Below command took over 46 minutes. The slow part was Fetching hashicorp/aws 5.26.0. Previously, like week or two ago this command took around 5 minutes, which still is way too slow, but today it took 10 longer.

Using MacOS. The only network related thing that is slow on this machine is Terraform.

time terraform providers lock -platform=darwin_amd64 -platform=darwin_arm64 -platform=linux_amd64 -platform=windows_amd64

- Fetching hashicorp/aws 5.26.0 for darwin_amd64...
- Retrieved hashicorp/aws 5.26.0 for darwin_amd64 (signed by HashiCorp)
- Fetching hashicorp/random 3.5.1 for darwin_amd64...
- Retrieved hashicorp/random 3.5.1 for darwin_amd64 (signed by HashiCorp)
- Fetching hashicorp/random 3.5.1 for darwin_arm64...
- Retrieved hashicorp/random 3.5.1 for darwin_arm64 (signed by HashiCorp)
- Fetching hashicorp/aws 5.26.0 for darwin_arm64...
- Retrieved hashicorp/aws 5.26.0 for darwin_arm64 (signed by HashiCorp)
- Fetching hashicorp/aws 5.26.0 for linux_amd64...
- Retrieved hashicorp/aws 5.26.0 for linux_amd64 (signed by HashiCorp)
- Fetching hashicorp/random 3.5.1 for linux_amd64...
- Retrieved hashicorp/random 3.5.1 for linux_amd64 (signed by HashiCorp)
- Fetching hashicorp/aws 5.26.0 for windows_amd64...
- Retrieved hashicorp/aws 5.26.0 for windows_amd64 (signed by HashiCorp)
- Fetching hashicorp/random 3.5.1 for windows_amd64...
- Retrieved hashicorp/random 3.5.1 for windows_amd64 (signed by HashiCorp)
- Obtained hashicorp/aws checksums for darwin_amd64; All checksums for this platform were already tracked in the lock file
- Obtained hashicorp/aws checksums for darwin_arm64; Additional checksums for this platform are now tracked in the lock file
- Obtained hashicorp/aws checksums for linux_amd64; Additional checksums for this platform are now tracked in the lock file
- Obtained hashicorp/aws checksums for windows_amd64; Additional checksums for this platform are now tracked in the lock file
- Obtained hashicorp/random checksums for darwin_amd64; All checksums for this platform were already tracked in the lock file
- Obtained hashicorp/random checksums for darwin_arm64; All checksums for this platform were already tracked in the lock file
- Obtained hashicorp/random checksums for linux_amd64; Additional checksums for this platform are now tracked in the lock file
- Obtained hashicorp/random checksums for windows_amd64; Additional checksums for this platform are now tracked in the lock file

Success! Terraform has updated the lock file.

Review the changes in .terraform.lock.hcl and then commit to your
version control system to retain the new checksums.

terraform providers lock -platform=darwin_amd64 -platform=darwin_arm64    22.81s user 8.99s system 1% cpu 46:02.31 total

@jsyrjala
Copy link

jsyrjala commented Nov 20, 2023

Seems that https://releases.hashicorp.com/ is some times extremely slow for downloading. Download speeds are e.g. 34,4KB/s. This is with wget binary so likely it is not terraform app, but likely something in the site hosting these files.

➜  tmp wget https://releases.hashicorp.com/terraform-provider-template/2.2.0/terraform-provider-template_2.2.0_darwin_amd64.zip
--2023-11-20 14:12:36--  https://releases.hashicorp.com/terraform-provider-template/2.2.0/terraform-provider-template_2.2.0_darwin_amd64.zip
Resolving releases.hashicorp.com (releases.hashicorp.com)... 18.165.140.5, 18.165.140.94, 18.165.140.83, ...
Connecting to releases.hashicorp.com (releases.hashicorp.com)|18.165.140.5|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7438707 (7,1M) [application/zip]
Saving to: ‘terraform-provider-template_2.2.0_darwin_amd64.zip’

terraform-provider-template_2.2.0_darwin_amd64.zip         100%[=====================================================================================================================================>]   7,09M  13,7MB/s    in 0,5s    

2023-11-20 14:12:37 (13,7 MB/s) - ‘terraform-provider-template_2.2.0_darwin_amd64.zip’ saved [7438707/7438707]

➜  tmp wget https://releases.hashicorp.com/terraform-provider-aws/5.26.0/terraform-provider-template_5.26.0_darwin_amd64.zip
--2023-11-20 14:13:03--  https://releases.hashicorp.com/terraform-provider-aws/5.26.0/terraform-provider-template_5.26.0_darwin_amd64.zip
Resolving releases.hashicorp.com (releases.hashicorp.com)... 18.165.140.5, 18.165.140.94, 18.165.140.83, ...
Connecting to releases.hashicorp.com (releases.hashicorp.com)|18.165.140.5|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2023-11-20 14:13:04 ERROR 404: Not Found.

➜  tmp wget https://releases.hashicorp.com/terraform-provider-aws/5.26.0/terraform-provider-aws_5.26.0_darwin_arm64.zip     
--2023-11-20 14:13:31--  https://releases.hashicorp.com/terraform-provider-aws/5.26.0/terraform-provider-aws_5.26.0_darwin_arm64.zip
Resolving releases.hashicorp.com (releases.hashicorp.com)... 18.165.140.5, 18.165.140.94, 18.165.140.83, ...
Connecting to releases.hashicorp.com (releases.hashicorp.com)|18.165.140.5|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 85950151 (82M) [application/zip]
Saving to: ‘terraform-provider-aws_5.26.0_darwin_arm64.zip’

terraform-provider-aws_5.26.0_darwin_arm64.zip             100%[=====================================================================================================================================>]  81,97M  18,5MB/s    in 4,6s    

2023-11-20 14:13:35 (17,9 MB/s) - ‘terraform-provider-aws_5.26.0_darwin_arm64.zip’ saved [85950151/85950151]

➜  tmp wget https://releases.hashicorp.com/terraform-provider-aws/5.26.0/terraform-provider-aws_5.26.0_darwin_arm64.zip
--2023-11-20 14:13:49--  https://releases.hashicorp.com/terraform-provider-aws/5.26.0/terraform-provider-aws_5.26.0_darwin_arm64.zip
Resolving releases.hashicorp.com (releases.hashicorp.com)... 18.165.140.5, 18.165.140.94, 18.165.140.83, ...
Connecting to releases.hashicorp.com (releases.hashicorp.com)|18.165.140.5|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 85950151 (82M) [application/zip]
Saving to: ‘terraform-provider-aws_5.26.0_darwin_arm64.zip.1’

terraform-provider-aws_5.26.0_darwin_arm64.zip.1             5%[======>                                                                                                                               ]   4,32M  34,4KB/s    eta 11m 51s^C
➜  tmp wget https://releases.hashicorp.com/terraform-provider-aws/5.26.0/terraform-provider-aws_5.26.0_darwin_arm64.zip
--2023-11-20 14:14:32--  https://releases.hashicorp.com/terraform-provider-aws/5.26.0/terraform-provider-aws_5.26.0_darwin_arm64.zip
Resolving releases.hashicorp.com (releases.hashicorp.com)... 18.165.140.94, 18.165.140.83, 18.165.140.50, ...
Connecting to releases.hashicorp.com (releases.hashicorp.com)|18.165.140.94|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 85950151 (82M) [application/zip]
Saving to: ‘terraform-provider-aws_5.26.0_darwin_arm64.zip.2’

terraform-provider-aws_5.26.0_darwin_arm64.zip.2             7%[=========>                                                                                                                            ]   6,25M  29,0KB/s    eta 12m 41s

@zhenrong-wang
Copy link

I think terraform init is slow even when its working!
It adds 10 seconds every time its executed in a minimal AWS infra test example of mine and it needs to be executed every time in CI. It would be good if it had some serialisation of versions to determine if it needs to do heavy lifting or just use the existing cache and be snappier.

From my experience, only the first time of init takes time to download (cache) the provider binary. As long as the binary got downloaded and cached to local environment, init will take effect instantly.

One solution might be:

Download and unzip all the provider binary(ies) to your local terraform provider registry.

Reference URL: https://releases.hashicorp.com

Most dev providers can be downloaded from their github repositories.

@queglay
Copy link

queglay commented Nov 23, 2023

Perhaps theres something I'm not getting. run locally it takes about 8secs at the moment, and reuses the lock file I have committed. I still don't think thats fast for my basic project, doesn't seem like good caching behaviour to me.

user@MacBook-Pro-2 tf-aws-lambda-nebula % terraform init

Initializing Terraform Cloud...
Initializing modules...

Initializing provider plugins...
- Reusing previous version of hashicorp/archive from the dependency lock file
- Reusing previous version of hashicorp/aws from the dependency lock file
- Using previously-installed hashicorp/archive v2.4.0
- Using previously-installed hashicorp/aws v4.4.0

Terraform Cloud has been successfully initialized!

and my circle ci runner + terraform cloud runs always have to do more than that too even with the updated lock file:

Initializing Terraform Cloud...
Initializing modules...
- bucket_policy_attachments in modules/s3-shared-bucket-policy
- certificates_bucket in modules/s3-nebula-bucket
- scripts_bucket in modules/s3-nebula-bucket

Initializing provider plugins...
- Reusing previous version of hashicorp/aws from the dependency lock file
- Reusing previous version of hashicorp/archive from the dependency lock file
- Installing hashicorp/aws v4.4.0...
- Installed hashicorp/aws v4.4.0 (signed by HashiCorp)
- Installing hashicorp/archive v2.4.0...
- Installed hashicorp/archive v2.4.0 (signed by HashiCorp)

Terraform has made some changes to the provider dependency selections recorded
in the .terraform.lock.hcl file. Review those changes and commit them to your
version control system if they represent changes you intended to make.

Terraform Cloud has been successfully initialized!

@queglay
Copy link

queglay commented Nov 23, 2023

Ok I took a look at fixing this - it was due to my caching not setup properly. but still takes about 6 seconds here when on my mac (speed test is about 108MBit/s from Melbourne Australia):
Initializing Terraform Cloud...

init in cicrcle ci is now 1-2 secs though with caching fixed so that is nice to know.

@swiknaba
Copy link

swiknaba commented Feb 2, 2024

For me, terraform init downloads files at a whopping speed of 150 kb/s. When I download anything else via the terminal (e.g. brew install... or docker pull) I get around 50 MBit.

Terraform is consistently slow for me, it's a nightmare (and it's the only slow one on my machine, so definitely a fault of terraform, not my network or machine config).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug v0.13 Issues (primarily bugs) reported against v0.13 releases v0.15 Issues (primarily bugs) reported against v0.15 releases v1.0 Issues (primarily bugs) reported against v1.0 releases v1.2 Issues (primarily bugs) reported against v1.2 releases waiting for reproduction unable to reproduce issue without further information
Projects
None yet
Development

No branches or pull requests