I Follow this tutorial https://learn.hashicorp.com/tutorials/terraform/aws-build?in=terraform/aws-get-started
terraform --version
Terraform v0.13.5
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 2.70"
}
}
}
provider "aws" {
profile = "default"
region = "us-west-2"
}
resource "aws_instance" "example" {
ami = "ami-830c94e3"
instance_type = "t2.micro"
}
Initializing the backend...
Initializing provider plugins...
The following providers do not have any version constraints in configuration,
so the latest version was installed.
To prevent automatic upgrades to new major versions that may contain breaking
changes, we recommend adding version constraints in a required_providers block
in your configuration, with the constraint strings suggested below.
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.
Initializing the backend...
Initializing provider plugins...
Error: Failed to query available provider packages
Could not retrieve the list of available versions for provider hashicorp/aws:
could not connect to registry.terraform.io: Failed to request discovery
document: Get "https://registry.terraform.io/.well-known/terraform.json":
net/http: request canceled while waiting for connection (Client.Timeout
exceeded while awaiting headers)
terraform initHas anyone had any luck with resolving this issue? I too am experiencing the same error on multiple machines
MacBook Pro (Retina, 15-inch, Mid 2015)
MacOS Mojave 10.14.4
2.8 GHz i7
16 GB
MacBook Pro (Retina, 13-inch, Mid 2017)
MacOS Mojave 10.14.1
2.3 GHz i7
8 GB
Both machines are experiencing the same issue, attached image is the 13-inch MacBook output, but the other machine is experiencing the same error.

This looks like a duplicate of #26532, and is likely to be some sort of local network configuration issue, possibly DNS. There are several posts in the linked issue which offer suggestions on ways to proceed. Hopefully one of those can get you unblocked!
Closing as duplicate.
I was able to resolve the issue by building terraform locally with CGO_ENABLED=1 and putting the bin in your /usr/local/bin
Follow the instructions here for a manual install.
Hope that helps.
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.