Closed6
terraform provider install from terraform registry vs filesystem_mirror vs TP_PLUGIN_CACHE_DIR
ピン留めされたアイテム

- filesystem_mirror: 6s
- download from terraform registry: 36s
- TF_PLUGIN_CACHE_DIR: 1s
Environment
- 29 mbps(fast.com)
- intel Mac 2.3 GHz Core 4 Quad Intel Core i7

terraform.lock.hcl
provider "registry.terraform.io/hashicorp/aws" {
version = "5.84.0"
constraints = "~> 5.0"
hashes = [
"h1:TpsSFMkiuLC1V29n4Ov99g4L6jlsBmBMWxqDX3GZNww=",
"zh:078f77438aba6ec8bf9154b7d223e5c71c48d805d6cd3bcf9db0cc1e82668ac3",
"zh:1f6591ff96be00501e71b792ed3a5a14b21ff03afec9a1c4a3fd9300e6e5b674",
"zh:2ab694e022e81dd74485351c5836148a842ed71cf640664c9d871cb517b09602",
"zh:33c8ccb6e3dc496e828a7572dd981366c6271075c1189f249b9b5236361d7eff",
"zh:6f31068ebad1d627e421c72ccdaafe678c53600ca73714e977bf45ff43ae5d17",
"zh:7488623dccfb639347cae66f9001d39cf06b92e8081975235a1ac3a0ac3f44aa",
"zh:7f042b78b9690a8725c95b91a70fc8e264011b836605bcc342ac297b9ea3937d",
"zh:88b56ac6c7209dc0a775b79975a371918f3aed8f015c37d5899f31deff37c61a",
"zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425",
"zh:a1979ba840d704af0932f8de5f541cbb4caa9b6bbd25ed552a24e6772175ba07",
"zh:b058c0533dae580e69d1adbc1f69e6a80632374abfc10e8634d06187a108e87b",
"zh:c88610af9cf957f8dcf4382e0c9ca566ef10e3290f5de01d4d90b2d81b078aa8",
"zh:e9562c055a2247d0c287772b55abef468c79f8d66a74780fe1c5e5dae1a284a9",
"zh:f7a7c71d28441d925a25c08c4485c015b2d9f0338bc9707443e91ff8e161d3d9",
"zh:fee533e81976d0900aa6fa443dc54ef171cbd901847f28a6e8edb1d161fa6fde",
]
}

install from filesystem_mirror
provider_installation {
filesystem_mirror {
path = "/Users/sho/terraform-mirror"
include = ["hashicorp/aws"]
}
direct {}
}
Initializing provider plugins...
- Reusing previous version of hashicorp/aws from the dependency lock file
2025-01-28T01:28:01.642+0900 [WARN] ignoring file "registry.terraform.io/hashicorp/aws/5.84.0.json" as possible package for registry.terraform.io/hashicorp/aws: filename lacks expected prefix "terraform-provider-aws_"
2025-01-28T01:28:01.642+0900 [WARN] ignoring file "registry.terraform.io/hashicorp/aws/index.json" as possible package for registry.terraform.io/hashicorp/aws: filename lacks expected prefix "terraform-provider-aws_"
2025-01-28T01:28:01.642+0900 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/hashicorp/aws v5.84.0 for darwin_amd64 at /Users/sho/terraform-mirror/registry.terraform.io/hashicorp/aws/terraform-provider-aws_5.84.0_darwin_amd64.zip
2025-01-28T01:28:01.642+0900 [DEBUG] Service discovery for registry.terraform.io at https://registry.terraform.io/.well-known/terraform.json
2025-01-28T01:28:01.642+0900 [TRACE] HTTP client GET request to https://registry.terraform.io/.well-known/terraform.json
2025-01-28T01:28:01.806+0900 [DEBUG] GET https://registry.terraform.io/v1/providers/hashicorp/aws/versions
2025-01-28T01:28:01.806+0900 [TRACE] HTTP client GET request to https://registry.terraform.io/v1/providers/hashicorp/aws/versions
2025-01-28T01:28:01.948+0900 [TRACE] providercache.fillMetaCache: scanning directory .terraform/providers
2025-01-28T01:28:01.948+0900 [TRACE] getproviders.SearchLocalDirectory: failed to resolve symlinks for .terraform/providers: lstat .terraform/providers: no such file or directory
2025-01-28T01:28:01.948+0900 [TRACE] providercache.fillMetaCache: error while scanning directory .terraform/providers: cannot search .terraform/providers: lstat .terraform/providers: no such file or directory
- Installing hashicorp/aws v5.84.0...
2025-01-28T01:28:01.948+0900 [TRACE] providercache.Dir.InstallPackage: installing registry.terraform.io/hashicorp/aws v5.84.0 from /Users/sho/terraform-mirror/registry.terraform.io/hashicorp/aws/terraform-provider-aws_5.84.0_darwin_amd64.zip
2025-01-28T01:28:07.487+0900 [TRACE] providercache.fillMetaCache: scanning directory .terraform/providers
2025-01-28T01:28:07.488+0900 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/hashicorp/aws v5.84.0 for darwin_amd64 at .terraform/providers/registry.terraform.io/hashicorp/aws/5.84.0/darwin_amd64
2025-01-28T01:28:07.488+0900 [TRACE] providercache.fillMetaCache: including .terraform/providers/registry.terraform.io/hashicorp/aws/5.84.0/darwin_amd64 as a candidate package for registry.terraform.io/hashicorp/aws 5.84.0
- Installed hashicorp/aws v5.84.0 (unauthenticated)

install from terraform registry
- Installing hashicorp/aws v5.84.0...
2025-01-28T01:40:41.299+0900 [TRACE] providercache.Dir.InstallPackage: installing registry.terraform.io/hashicorp/aws v5.84.0 from https://releases.hashicorp.com/terraform-provider-aws/5.84.0/terraform-provider-aws_5.84.0_darwin_amd64.zip
2025-01-28T01:40:41.299+0900 [TRACE] HTTP client GET request to https://releases.hashicorp.com/terraform-provider-aws/5.84.0/terraform-provider-aws_5.84.0_darwin_amd64.zip
2025-01-28T01:41:17.829+0900 [DEBUG] Provider signed by 34365D9472D7468F HashiCorp Security (hashicorp.com/security) <security@hashicorp.com>
2025-01-28T01:41:24.326+0900 [TRACE] providercache.fillMetaCache: scanning directory .terraform/providers
2025-01-28T01:41:24.326+0900 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/hashicorp/aws v5.84.0 for darwin_amd64 at .terraform/providers/registry.terraform.io/hashicorp/aws/5.84.0/darwin_amd64
2025-01-28T01:41:24.326+0900 [TRACE] providercache.fillMetaCache: including .terraform/providers/registry.terraform.io/hashicorp/aws/5.84.0/darwin_amd64 as a candidate package for registry.terraform.io/hashicorp/aws 5.84.0
- Installed hashicorp/aws v5.84.0 (signed by HashiCorp)

実装的にはここで install してて、terraform registry から install する時と基本同じ。違いは download step を省略していきなり unzip してるとこ
あと多分認証のステップを一部飛ばしてるはず(↓の1個目とか)

TF_PLUGIN_CACHE_DIR 使うと unzip する手間も省けるため最速
Initializing provider plugins...
- Reusing previous version of hashicorp/aws from the dependency lock file
2025-01-28T02:03:18.568+0900 [DEBUG] Service discovery for registry.terraform.io at https://registry.terraform.io/.well-known/terraform.json
2025-01-28T02:03:18.569+0900 [TRACE] HTTP client GET request to https://registry.terraform.io/.well-known/terraform.json
2025-01-28T02:03:19.018+0900 [DEBUG] GET https://registry.terraform.io/v1/providers/hashicorp/aws/versions
2025-01-28T02:03:19.018+0900 [TRACE] HTTP client GET request to https://registry.terraform.io/v1/providers/hashicorp/aws/versions
2025-01-28T02:03:19.164+0900 [TRACE] providercache.fillMetaCache: scanning directory .terraform/providers
2025-01-28T02:03:19.164+0900 [TRACE] getproviders.SearchLocalDirectory: failed to resolve symlinks for .terraform/providers: lstat .terraform/providers: no such file or directory
2025-01-28T02:03:19.164+0900 [TRACE] providercache.fillMetaCache: error while scanning directory .terraform/providers: cannot search .terraform/providers: lstat .terraform/providers: no such file or directory
2025-01-28T02:03:19.164+0900 [TRACE] providercache.fillMetaCache: scanning directory /Users/sho/.terraform.d/plugin-cache
2025-01-28T02:03:19.167+0900 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/carlpett/sops v0.7.2 for darwin_amd64 at /Users/sho/.terraform.d/plugin-cache/registry.terraform.io/carlpett/sops/0.7.2/darwin_amd64
2025-01-28T02:03:19.169+0900 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/hashicorp/aws v5.84.0 for darwin_amd64 at /Users/sho/.terraform.d/plugin-cache/registry.terraform.io/hashicorp/aws/5.84.0/darwin_amd64
2025-01-28T02:03:19.169+0900 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/hashicorp/google v4.49.0 for darwin_amd64 at /Users/sho/.terraform.d/plugin-cache/registry.terraform.io/hashicorp/google/4.49.0/darwin_amd64
2025-01-28T02:03:19.170+0900 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/hashicorp/google v4.53.1 for darwin_amd64 at /Users/sho/.terraform.d/plugin-cache/registry.terraform.io/hashicorp/google/4.53.1/darwin_amd64
2025-01-28T02:03:19.171+0900 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/hashicorp/null v3.2.1 for darwin_amd64 at /Users/sho/.terraform.d/plugin-cache/registry.terraform.io/hashicorp/null/3.2.1/darwin_amd64
2025-01-28T02:03:19.172+0900 [TRACE] providercache.fillMetaCache: including /Users/sho/.terraform.d/plugin-cache/registry.terraform.io/hashicorp/aws/5.84.0/darwin_amd64 as a candidate package for registry.terraform.io/hashicorp/aws 5.84.0
2025-01-28T02:03:19.172+0900 [TRACE] providercache.fillMetaCache: including /Users/sho/.terraform.d/plugin-cache/registry.terraform.io/hashicorp/google/4.49.0/darwin_amd64 as a candidate package for registry.terraform.io/hashicorp/google 4.49.0
2025-01-28T02:03:19.172+0900 [TRACE] providercache.fillMetaCache: including /Users/sho/.terraform.d/plugin-cache/registry.terraform.io/hashicorp/google/4.53.1/darwin_amd64 as a candidate package for registry.terraform.io/hashicorp/google 4.53.1
2025-01-28T02:03:19.172+0900 [TRACE] providercache.fillMetaCache: including /Users/sho/.terraform.d/plugin-cache/registry.terraform.io/hashicorp/null/3.2.1/darwin_amd64 as a candidate package for registry.terraform.io/hashicorp/null 3.2.1
2025-01-28T02:03:19.172+0900 [TRACE] providercache.fillMetaCache: including /Users/sho/.terraform.d/plugin-cache/registry.terraform.io/carlpett/sops/0.7.2/darwin_amd64 as a candidate package for registry.terraform.io/carlpett/sops 0.7.2
- Using hashicorp/aws v5.84.0 from the shared cache directory
2025-01-28T02:03:20.771+0900 [TRACE] providercache.Dir.LinkFromOtherCache: linking registry.terraform.io/hashicorp/aws v5.84.0 from existing cache /Users/sho/.terraform.d/plugin-cache/registry.terraform.io/hashicorp/aws/5.84.0/darwin_amd64 to .terraform/providers/registry.terraform.io/hashicorp/aws/5.84.0/darwin_amd64
2025-01-28T02:03:20.771+0900 [TRACE] providercache.fillMetaCache: scanning directory .terraform/providers
2025-01-28T02:03:20.772+0900 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/hashicorp/aws v5.84.0 for darwin_amd64 at .terraform/providers/registry.terraform.io/hashicorp/aws/5.84.0/darwin_amd64
2025-01-28T02:03:20.772+0900 [TRACE] providercache.fillMetaCache: including .terraform/providers/registry.terraform.io/hashicorp/aws/5.84.0/darwin_amd64 as a candidate package for registry.terraform.io/hashicorp/aws 5.84.0
Terraform has been successfully initialized!
ちなみに install の処理はここでやってる
このスクラップは2025/03/14にクローズされました