A good number of times, when I run terraform init
it get stuck at “- Installing hashicorp/aws v4.63.0…” for a really long time. Sometimes, it continues and other times I just quit the run. Could it just be my network or there’s something else?
Hi @miracleajayi4,
The AWS provider distribution packages are relatively large (on the order of hundreds of megabytes), so a potential simple explanation is that the connectivity between you and the nearest distribution server is slow or has a lot of packet loss.
Do you think that might be a plausible explanation, or do you think there’s something more unusual happening?
No, I don’t think anything unusual. I just think it’s my network. Cause I tried testing my internet speed using M-Lab afterwards, and it told me that my internet connection is too slow that it couldn’t even run the test. It was very saddening I tell you.
Hi @miracleajayi4,
In this case it may help for you to configure the optional Provider Plugin Cache, which will allow Terraform to reuse an already-downloaded copy of this provider as long is the package in the cache matches what’s in your .terraform.lock.hcl
file, which is where Terraform “remembers” which provider packages you used with this configuration most recently.
Note that the link above is describing the CLI Configuration files, which are different than the .tf
files you use to describe your infrastructure: they tell Terraform how to behave on your particular system. See the content near the top of that page for where to create the CLI Configuration file on your system.
To benefit from this once enabled, you can:
- Run
terraform init
once in a clean working directory so Terraform will download the provider from its original source. This will probably be slow for you, but let it finish so that Terraform can populate the cache. -
terraform init
will have created or updated the file.terraform.lock.hcl
to record the version and checksum just downloaded into the cache. Add this file to your version control system so Terraform can use it in future. - Now whenever you run
terraform init
in future, Terraform will first check whether the local cache contains the package mentioned in the lock file. If so, it will use the copy from the cache instead of downloading it over the internet again.
As long as you keep using the same provider version on that same computer, Terraform should not need to download this provider package over the internet again when you are working with this configuration.