Skip to content

Commit 846af72

Browse files
feat: add HuaweiCloud Provider Mirror Guide
1 parent 12e01e2 commit 846af72

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
page_title: "HuaweiCloud Provider Mirror Guide"
3+
---
4+
5+
# Setting a Network Mirror
6+
7+
Sometimes, running the `terraform init` command to download and install providers can be too slow,
8+
or it may even fail as follows:
9+
10+
```text
11+
Initializing provider plugins...
12+
- Finding huaweicloud/huaweicloud versions matching "1.65.0"...
13+
14+
│ Error: Failed to query available provider packages
15+
16+
│ Could not retrieve the list of available versions for provider huaweicloud/huaweicloud: could not connect to registry.terraform.io: failed to request discovery document: Get
17+
│ "https://registry.terraform.io/.well-known/terraform.json": dial tcp 3.165.82.91:443: connect: no route to host
18+
19+
```
20+
21+
or
22+
23+
```text
24+
Initializing provider plugins...
25+
- Finding huaweicloud/huaweicloud versions matching "1.66.0"...
26+
27+
│ Error: Failed to query available provider packages
28+
29+
│ Could not retrieve the list of available versions for provider huaweicloud/huaweicloud: could not query provider registry for registry.terraform.io/huaweicloud/huaweicloud: the
30+
│ request failed after 3 attempts, please try again later: Get "https://registry.terraform.io/v1/providers/huaweicloud/huaweicloud/versions": context deadline exceeded
31+
│ (Client.Timeout exceeded while awaiting headers)
32+
33+
```
34+
35+
Since Terraform CLI v0.13.2, it provides the [network_mirror](https://developer.hashicorp.com/terraform/cli/config/config-file#network_mirror) feature.
36+
To fix the issues of downloading HuaweiCloud providers, HuaweiCloud provides a mirror service.
37+
You can set the following configuration in the [CLI Configuration File](https://developer.hashicorp.com/terraform/cli/config/config-file):
38+
39+
```terraform
40+
provider_installation {
41+
network_mirror {
42+
url = "https://tf-mirror.obs.cn-north-4.myhuaweicloud.com/"
43+
# Set HuaweiCloud providers to download from the mirror service.
44+
include = ["registry.terraform.io/huaweicloud/huaweicloud"]
45+
}
46+
direct {
47+
# For other providers, download from the Terraform Registry.
48+
exclude = ["registry.terraform.io/huaweicloud/huaweicloud"]
49+
}
50+
}
51+
```
52+
53+
### Example on Linux
54+
55+
- Create CLI configuration file `.terraformrc` and placed directly in the home directory of the relevant user.
56+
57+
```shell
58+
tee ~/.terraformrc <<-'EOF'
59+
provider_installation {
60+
network_mirror {
61+
url = "https://tf-mirror.obs.cn-north-4.myhuaweicloud.com/"
62+
# Set HuaweiCloud providers to download from the mirror service.
63+
include = ["registry.terraform.io/huaweicloud/huaweicloud"]
64+
}
65+
direct {
66+
# For other providers, download from the Terraform Registry.
67+
exclude = ["registry.terraform.io/huaweicloud/huaweicloud"]
68+
}
69+
}
70+
EOF
71+
```
72+
73+
- When you run `terraform init` you will find the following output in the log file:
74+
75+
```text
76+
2024-07-29T11:02:36.511+0800 [INFO] Go runtime version: go1.22.1
77+
2024-07-29T11:02:36.511+0800 [INFO] CLI args: []string{"terraform", "init"}
78+
2024-07-29T11:02:36.511+0800 [DEBUG] Attempting to open CLI config file: /home/huawei/.terraformrc
79+
2024-07-29T11:02:36.511+0800 [INFO] Loading CLI configuration from /home/huawei/.terraformrc
80+
2024-07-29T11:02:36.511+0800 [DEBUG] checking for credentials in "/home/huawei/.terraform.d/plugins"
81+
2024-07-29T11:02:36.511+0800 [DEBUG] Explicit provider installation configuration is set
82+
2024-07-29T11:02:36.512+0800 [INFO] CLI command args: []string{"init"}
83+
2024-07-29T11:02:36.514+0800 [DEBUG] New state was assigned lineage "f234445e-7ddf-cf48-ade2-bb3ba4a9b5aa"
84+
2024-07-29T11:02:36.514+0800 [DEBUG] checking for provisioner in "."
85+
2024-07-29T11:02:36.523+0800 [DEBUG] checking for provisioner in "/usr/bin"
86+
2024-07-29T11:02:36.523+0800 [DEBUG] checking for provisioner in "/home/huawei/.terraform.d/plugins"
87+
2024-07-29T11:02:36.525+0800 [DEBUG] Querying available versions of provider registry.terraform.io/huaweicloud/huaweicloud at network mirror https://tf-mirror.obs.cn-north-4.myhuaweicloud.com/
88+
2024-07-29T11:02:36.525+0800 [DEBUG] GET https://tf-mirror.obs.cn-north-4.myhuaweicloud.com/registry.terraform.io/huaweicloud/huaweicloud/index.json
89+
2024-07-29T11:02:36.919+0800 [DEBUG] Finding package URL for registry.terraform.io/huaweicloud/huaweicloud v1.66.3 on linux_amd64 via network mirror https://tf-mirror.obs.cn-north-4.myhuaweicloud.com/
90+
2024-07-29T11:02:36.919+0800 [DEBUG] GET https://tf-mirror.obs.cn-north-4.myhuaweicloud.com/registry.terraform.io/huaweicloud/huaweicloud/1.66.3.json
91+
```

0 commit comments

Comments
 (0)