momo's Blog.

.terraform.lock.hcl是否应该包含在git仓库中

字数统计: 144阅读时长: 1 min
2023/04/19 Share

前言

对于多人协作的 Terraform仓库, 在git中包含 .terraform.lock.hcl 可能会出现以下错误

1
2
3
4
5
6
7
8
9
10
Initializing provider plugins...
- Reusing previous version of aliyun/alicloud from the dependency lock file
- Using aliyun/alicloud v1.203.0 from the shared cache directory

Error: Failed to install provider from shared cache

Error while importing aliyun/alicloud v1.203.0 from the shared cache
directory: the provider cache at .terraform/providers has a copy of
│ registry.terraform.io/aliyun/alicloud 1.203.0 that doesn't match any of the
│ checksums recorded in the dependency lock file.

官方是希望提交到此仓库中, 但是针对于不同系统checksum也不一样。

解决

1
terraform providers lock -platform=darwin_amd64 -platform=darwin_arm64 -platform=linux_amd64
CATALOG
  1. 1. 前言
  2. 2. 解决